srielau opened a new pull request, #60483: URL: https://github.com/apache/spark/pull/60483
### What changes were proposed in this pull request? This PR applies SQL PATH resolution to partially qualified object names in addition to unqualified names. The change introduces shared identifier PATH expansion where schema entries qualify one-part names and catalog entries qualify two-part names. Routines, relations, variables, and procedures use this shared ordering, while names beginning with a registered catalog remain directly qualified and bypass PATH. The previous special-case mini-path for `builtin.name` and `session.name` is removed in favor of normal PATH ordering. The built-in `DEFAULT_PATH` now includes catalog entries for `system` and `CURRENT_CATALOG`. The existing `spark.sql.legacy.persistentCatalogFirst` configuration controls their order: `false` places `system` first, while `true` places the current catalog first. Explicit `SET PATH` and `spark.sql.defaultPath` values remain authoritative. The PR also adds `CURRENT_CATALOG` as a dynamic PATH element, updates SQL PATH documentation and generated SQL test results, and removes the obsolete error that rejected catalog-only PATH entries. ### Why are the changes needed? Before this change, SQL PATH was used for unqualified routines, relations, and variables, but partially qualified names used separate mini-path logic limited to the system and current catalogs. For example, `session.t` did not follow arbitrary catalog entries in the configured PATH. That behavior made resolution inconsistent and duplicated ordering logic across object types. Using the normal PATH for two-part names makes resolution order explicit, consistent, and shared across routines, relations, variables, and procedures. ### Does this PR introduce _any_ user-facing change? Yes. Partially qualified names now follow catalog entries in SQL PATH. For example: ```sql SET PATH = cat2, cat1, system; SELECT * FROM ns.t; ``` The query searches `cat2.ns.t` before `cat1.ns.t`. The same ordering applies to partially qualified routines, variables, and procedures as appropriate. For the built-in default path, `session.t` and `builtin.f()` search the `system` catalog before the current catalog by default. Setting `spark.sql.legacy.persistentCatalogFirst=true` reverses those two catalog entries. Fully catalog-qualified names continue to bypass PATH. ### How was this patch tested? Added focused positive, negative, and ordering tests for routines, relations, variables, procedures, resolver guards, the session catalog, and V2 catalogs. The following focused checks passed: ```text build/sbt "sql/testOnly org.apache.spark.sql.SetPathSuite" build/sbt "sql/testOnly org.apache.spark.sql.RelationQualificationSuite" build/sbt "sql/testOnly org.apache.spark.sql.FunctionQualificationSuite" build/sbt "sql/testOnly org.apache.spark.sql.analysis.resolver.ResolverGuardSuite" build/sbt "sql/testOnly org.apache.spark.sql.connector.ProcedureSuite" build/sbt "sql/testOnly org.apache.spark.sql.connector.SqlPathV2CatalogSuite" build/sbt "sql/testOnly org.apache.spark.sql.JsonArraySuite" build/sbt "sql/testOnly org.apache.spark.sql.JsonValueSuite" build/sbt "catalyst/testOnly org.apache.spark.sql.connector.catalog.CatalogManagerSuite" build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z sql-path.sql" build/sbt ";sql/scalastyle;sql/Test/scalastyle" ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: OpenAI Codex CLI 0.167.1 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
