Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SPARK-39503][SQL] Add session catalog name for v1 database table and…
… function ### What changes were proposed in this pull request? - Add session catalog name in identifiers, then all identifiers will be 3 part name ### Why are the changes needed? To make it more clearer that this table or function comes from which catalog. It affects: - the scan table/permanent view of the query plan - the target table of the data writing - desc database - desc table - desc function Note that, we do not support temporary view since it does not belong to any database and catalog This a new appraoch of #36936 that: - add catalog field in identifier, so identifier just print catalog if defined - inject catalog at the beginning of identifier life ### Does this PR introduce _any_ user-facing change? maybe yes, so add a new config `spark.sql.legacy.nonIdentifierOutputCatalogName` to restore the old behavior ### How was this patch tested? change list: ```scala docs/sql-migration-guide.md | 1 + sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala | 10 +++++++--- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala | 28 ++++++++++++++++++--------- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/interface.scala | 1 + sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/identifiers.scala | 56 ++++++++++++++++++++++++++++++++++++++++++++--------- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/trees/TreeNode.scala | 4 ++-- sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/CatalogV2Implicits.scala | 13 +++++++++---- sql/catalyst/src/main/scala/org/apache/spark/sql/connector/catalog/LookupCatalog.scala | 8 ++++++-- sql/catalyst/src/main/scala/org/apache/spark/sql/internal/SQLConf.scala | 9 +++++++++ sql/core/src/main/scala/org/apache/spark/sql/DataFrameWriter.scala | 7 ++++--- sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala | 14 ++++++++------ sql/core/src/main/scala/org/apache/spark/sql/execution/command/functions.scala | 6 ++++-- sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/DescribeNamespaceExec.scala | 1 + sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveClientImpl.scala | 5 +++-- sql/hive/src/main/scala/org/apache/spark/sql/hive/client/HiveShim.scala | 5 +++-- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/ExternalCatalogSuite.scala | 5 +++-- sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala | 58 ++++++++++++++++++++++++++++++------------------------- sql/catalyst/src/test/scala/org/apache/spark/sql/connector/catalog/LookupCatalogSuite.scala | 4 +++- sql/core/src/test/scala/org/apache/spark/sql/DataFrameJoinSuite.scala | 4 +++- sql/core/src/test/scala/org/apache/spark/sql/DataFrameWriterV2Suite.scala | 13 +++++++++---- sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala | 7 +++++-- sql/core/src/test/scala/org/apache/spark/sql/execution/QueryExecutionSuite.scala | 4 +++- sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala | 39 ++++++++++++++++++++++++------------ sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala | 7 +++++-- sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala | 36 +++++++++++++++++++++-------------- sql/core/src/test/scala/org/apache/spark/sql/execution/command/PlanResolutionSuite.scala | 51 +++++++++++++++++++++++++++++---------------------- sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/DescribeNamespaceSuite.scala | 12 +++++++----- sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/DescribeTableSuite.scala | 2 ++ sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/ShowTblPropertiesSuite.scala | 3 ++- sql/core/src/test/scala/org/apache/spark/sql/execution/command/v2/DescribeNamespaceSuite.scala | 1 + sql/core/src/test/scala/org/apache/spark/sql/execution/metric/SQLMetricsSuite.scala | 3 ++- sql/hive/src/test/scala/org/apache/spark/sql/hive/MetastoreDataSourcesSuite.scala | 25 +++++++++++++----------- sql/hive/src/test/scala/org/apache/spark/sql/hive/StatisticsSuite.scala | 7 ++++--- sql/hive/src/test/scala/org/apache/spark/sql/hive/UDFSuite.scala | 9 +++++---- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveDDLSuite.scala | 27 ++++++++++++++++---------- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveExplainSuite.scala | 3 ++- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveSQLViewSuite.scala | 4 +++- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveTableScanSuite.scala | 13 +++++++------ sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/HiveUDFSuite.scala | 3 ++- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/SQLQuerySuite.scala | 8 +++++--- sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/DescribeTableSuite.scala | 2 ++ sql/hive/src/test/scala/org/apache/spark/sql/hive/execution/command/ShowFunctionsSuite sql/core/src/test/resources/sql-tests/results/charvarchar.sql.out | 20 ++++++++++++++++++- sql/core/src/test/resources/sql-tests/results/describe-table-after-alter-table.sql.out | 5 +++++ sql/core/src/test/resources/sql-tests/results/describe.sql.out | 22 +++++++++++++-------- sql/core/src/test/resources/sql-tests/results/explain-aqe.sql.out | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------- sql/core/src/test/resources/sql-tests/results/explain-cbo.sql.out | 8 ++++---- sql/core/src/test/resources/sql-tests/results/explain.sql.out | 100 +++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------ sql/core/src/test/resources/sql-tests/results/join-lateral.sql.out | 2 +- sql/core/src/test/resources/sql-tests/results/postgreSQL/create_view.sql.out | 40 +++++++++++++++++++++++++------------- sql/core/src/test/resources/sql-tests/results/postgreSQL/numeric.sql.out | 2 +- sql/core/src/test/resources/sql-tests/results/show-tables.sql.out | 10 ++++++---- sql/core/src/test/resources/sql-tests/results/show-tblproperties.sql.out | 2 +- sql/core/src/test/resources/sql-tests/results/udaf.sql.out | 4 ++-- sql/core/src/test/resources/sql-tests/results/udf/udf-udaf.sql.out | 4 ++-- ``` Closes #37021 from ulysses-you/output-catalog-2. Authored-by: ulysses-you <[email protected]> Signed-off-by: Wenchen Fan <[email protected]>
- Loading branch information