This is an automated email from the ASF dual-hosted git repository.

uros-b pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/spark.git


The following commit(s) were added to refs/heads/master by this push:
     new ec766bd19991 [SPARK-60625][SQL] Separate session-catalog SHOW goldens 
from V2 catalog coverage
ec766bd19991 is described below

commit ec766bd199915d090e4908ed5c268f7eded83267
Author: Vladan Vasić <[email protected]>
AuthorDate: Thu Oct 29 11:12:14 2026 +0000

    [SPARK-60625][SQL] Separate session-catalog SHOW goldens from V2 catalog 
coverage
    
    ### What changes were proposed in this pull request?
    
    - Keep `show-commands.sql` focused on the session catalog, including 
catalog listing, no-match patterns, all three `SHOW CURRENT` aliases, and 
collation queries.
    - Return to `default` in the current catalog before dropping the test 
database, instead of hardcoding `spark_catalog.default`.
    - Extend the existing `DataSourceV2SQLSuite` tests for custom catalogs, 
case-insensitive catalog patterns with and without `LIKE`, no-match patterns, 
and empty, multipart, and quoted namespaces for every `SHOW CURRENT` alias.
    - Regenerate the execution-result and analyzed-plan golden files.
    
    ### Why are the changes needed?
    
    Follow-up to SPARK-60583, tracked by 
https://issues.apache.org/jira/browse/SPARK-60625.
    
    The generic SQL input currently depends on loading an `InMemoryCatalog` and 
creating nested V2 namespaces. Those capabilities belong in the existing V2 
suite rather than being prerequisites for session-catalog golden tests. Its 
cleanup also switches to a specific catalog even though setup creates the 
database in the current one.
    
    The split preserves custom-catalog coverage while making the golden input 
independent of V2 catalog setup and a hardcoded session-catalog name.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No. Only tests and generated golden files change.
    
    ### How was this patch tested?
    
    Regenerated both golden files, then reran their execution and analyzer 
tests with generation disabled. Both tests passed. The two affected V2 tests 
also passed, and SQL test scalastyle reported zero errors or warnings.
    
    ```bash
    SPARK_GENERATE_GOLDEN_FILES=1 build/sbt \
      'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
show-commands.sql'
    
    build/sbt \
      'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
show-commands.sql' \
      'sql/testOnly org.apache.spark.sql.connector.DataSourceV2SQLSuiteV1Filter 
-- -z ShowCurrentNamespace -z ShowCatalogs' \
      'sql/Test/scalastyle'
    ```
    
    Also verified `git diff --check`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: OpenAI Codex CLI 0.164.0
    
    Closes #59869 from 
vladanvasi-db/vladanvasi-db/show-commands-catalog-isolation.
    
    Authored-by: Vladan Vasić <[email protected]>
    Signed-off-by: Uros Bojanic <[email protected]>
---
 .../analyzer-results/show-commands.sql.out         | 59 ++---------------
 .../resources/sql-tests/inputs/show-commands.sql   | 14 +---
 .../sql-tests/results/show-commands.sql.out        | 77 +++-------------------
 .../spark/sql/connector/DataSourceV2SQLSuite.scala | 42 ++++++++----
 4 files changed, 49 insertions(+), 143 deletions(-)

diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/show-commands.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/show-commands.sql.out
index 3b4d5ff84806..6bfe6a2d23f0 100644
--- 
a/sql/core/src/test/resources/sql-tests/analyzer-results/show-commands.sql.out
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/show-commands.sql.out
@@ -5,6 +5,12 @@ SHOW CATALOGS
 ShowCatalogsCommand
 
 
+-- !query
+SHOW CATALOGS 'non_existing_catalog_pattern'
+-- !query analysis
+ShowCatalogsCommand non_existing_catalog_pattern
+
+
 -- !query
 SHOW CURRENT NAMESPACE
 -- !query analysis
@@ -31,50 +37,6 @@ SHOW CURRENT DATABASE
 ShowCurrentNamespaceCommand
 
 
--- !query
-SET CATALOG 'testcat'
--- !query analysis
-SetCatalogCommand testcat
-
-
--- !query
-SHOW CURRENT NAMESPACE
--- !query analysis
-ShowCurrentNamespaceCommand
-
-
--- !query
-SHOW CATALOGS
--- !query analysis
-ShowCatalogsCommand
-
-
--- !query
-SHOW CATALOGS LIKE 'TEST*'
--- !query analysis
-ShowCatalogsCommand TEST*
-
-
--- !query
-SHOW CATALOGS 'non_existing_catalog_pattern'
--- !query analysis
-ShowCatalogsCommand non_existing_catalog_pattern
-
-
--- !query
-CREATE NAMESPACE testcat.show_commands_ns.`inner.ns`
--- !query analysis
-CreateNamespace false
-+- ResolvedNamespace 
org.apache.spark.sql.connector.catalog.InMemoryCatalog@xxxxxxxx, 
[show_commands_ns, inner.ns]
-
-
--- !query
-USE testcat.show_commands_ns.`inner.ns`
--- !query analysis
-SetCatalogAndNamespace
-+- ResolvedNamespace 
org.apache.spark.sql.connector.catalog.InMemoryCatalog@xxxxxxxx, 
[show_commands_ns, inner.ns]
-
-
 -- !query
 SHOW CURRENT SCHEMA
 -- !query analysis
@@ -82,19 +44,12 @@ ShowCurrentNamespaceCommand
 
 
 -- !query
-USE spark_catalog.default
+USE default
 -- !query analysis
 SetCatalogAndNamespace
 +- ResolvedNamespace V2SessionCatalog(spark_catalog), [default]
 
 
--- !query
-DROP NAMESPACE testcat.show_commands_ns.`inner.ns`
--- !query analysis
-DropNamespace false, false
-+- ResolvedNamespace 
org.apache.spark.sql.connector.catalog.InMemoryCatalog@xxxxxxxx, 
[show_commands_ns, inner.ns]
-
-
 -- !query
 DROP DATABASE show_commands_db
 -- !query analysis
diff --git a/sql/core/src/test/resources/sql-tests/inputs/show-commands.sql 
b/sql/core/src/test/resources/sql-tests/inputs/show-commands.sql
index 59676ac79e14..4ebff28d3d64 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/show-commands.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/show-commands.sql
@@ -1,24 +1,14 @@
---SET 
spark.sql.catalog.testcat=org.apache.spark.sql.connector.catalog.InMemoryCatalog
-
 SHOW CATALOGS;
+SHOW CATALOGS 'non_existing_catalog_pattern';
 SHOW CURRENT NAMESPACE;
 
 CREATE DATABASE show_commands_db;
 USE show_commands_db;
 SHOW CURRENT DATABASE;
 
-SET CATALOG 'testcat';
-SHOW CURRENT NAMESPACE;
-SHOW CATALOGS;
-SHOW CATALOGS LIKE 'TEST*';
-SHOW CATALOGS 'non_existing_catalog_pattern';
-
-CREATE NAMESPACE testcat.show_commands_ns.`inner.ns`;
-USE testcat.show_commands_ns.`inner.ns`;
 SHOW CURRENT SCHEMA;
 
-USE spark_catalog.default;
-DROP NAMESPACE testcat.show_commands_ns.`inner.ns`;
+USE default;
 DROP DATABASE show_commands_db;
 
 SHOW COLLATIONS LIKE 'utf8_*';
diff --git 
a/sql/core/src/test/resources/sql-tests/results/show-commands.sql.out 
b/sql/core/src/test/resources/sql-tests/results/show-commands.sql.out
index cb1b69ee0956..3d37e9ebd121 100644
--- a/sql/core/src/test/resources/sql-tests/results/show-commands.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/show-commands.sql.out
@@ -7,6 +7,14 @@ struct<catalog:string>
 spark_catalog
 
 
+-- !query
+SHOW CATALOGS 'non_existing_catalog_pattern'
+-- !query schema
+struct<catalog:string>
+-- !query output
+
+
+
 -- !query
 SHOW CURRENT NAMESPACE
 -- !query schema
@@ -39,81 +47,16 @@ struct<catalog:string,namespace:string>
 spark_catalog  show_commands_db
 
 
--- !query
-SET CATALOG 'testcat'
--- !query schema
-struct<>
--- !query output
-
-
-
--- !query
-SHOW CURRENT NAMESPACE
--- !query schema
-struct<catalog:string,namespace:string>
--- !query output
-testcat
-
-
--- !query
-SHOW CATALOGS
--- !query schema
-struct<catalog:string>
--- !query output
-spark_catalog
-testcat
-
-
--- !query
-SHOW CATALOGS LIKE 'TEST*'
--- !query schema
-struct<catalog:string>
--- !query output
-testcat
-
-
--- !query
-SHOW CATALOGS 'non_existing_catalog_pattern'
--- !query schema
-struct<catalog:string>
--- !query output
-
-
-
--- !query
-CREATE NAMESPACE testcat.show_commands_ns.`inner.ns`
--- !query schema
-struct<>
--- !query output
-
-
-
--- !query
-USE testcat.show_commands_ns.`inner.ns`
--- !query schema
-struct<>
--- !query output
-
-
-
 -- !query
 SHOW CURRENT SCHEMA
 -- !query schema
 struct<catalog:string,namespace:string>
 -- !query output
-testcat        show_commands_ns.`inner.ns`
-
-
--- !query
-USE spark_catalog.default
--- !query schema
-struct<>
--- !query output
-
+spark_catalog  show_commands_db
 
 
 -- !query
-DROP NAMESPACE testcat.show_commands_ns.`inner.ns`
+USE default
 -- !query schema
 struct<>
 -- !query output
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
 
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
index 24c4efbfb41d..62411d717cd6 100644
--- 
a/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
+++ 
b/sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
@@ -2310,24 +2310,34 @@ class DataSourceV2SQLSuiteV1Filter
       val schema = new StructType()
         .add("catalog", StringType, nullable = false)
         .add("namespace", StringType, nullable = false)
-      val df = sql("SHOW CURRENT NAMESPACE")
-      val rows = df.collect()
-
-      assert(df.schema === schema)
-      assert(rows.length == 1)
-      assert(rows(0).getAs[String](0) === expectedCatalogName)
-      assert(rows(0).getAs[String](1) === expectedNamespace)
+      Seq("NAMESPACE", "DATABASE", "SCHEMA").foreach { alias =>
+        val df = sql(s"SHOW CURRENT $alias")
+        val rows = df.collect()
+
+        assert(df.schema === schema)
+        assert(rows.length == 1)
+        assert(rows(0).getAs[String](0) === expectedCatalogName)
+        assert(rows(0).getAs[String](1) === expectedNamespace)
+      }
     }
 
     // Initially, the v2 session catalog is set as a current catalog.
     testShowCurrentNamespace("spark_catalog", "default")
 
-    sql("USE testcat")
-    testShowCurrentNamespace("testcat", "")
+    withNamespace("testcat.ns1.ns2", "testcat.ns1.`inner.ns`") {
+      withCurrentCatalogAndNamespace {
+        sql("SET CATALOG 'testcat'")
+        testShowCurrentNamespace("testcat", "")
 
-    sql("CREATE NAMESPACE testcat.ns1.ns2")
-    sql("USE testcat.ns1.ns2")
-    testShowCurrentNamespace("testcat", "ns1.ns2")
+        sql("CREATE NAMESPACE testcat.ns1.ns2")
+        sql("USE testcat.ns1.ns2")
+        testShowCurrentNamespace("testcat", "ns1.ns2")
+
+        sql("CREATE NAMESPACE testcat.ns1.`inner.ns`")
+        sql("USE testcat.ns1.`inner.ns`")
+        testShowCurrentNamespace("testcat", "ns1.`inner.ns`")
+      }
+    }
   }
 
   test("tableCreation: partition column case insensitive resolution") {
@@ -3994,6 +4004,14 @@ class DataSourceV2SQLSuiteV1Filter
 
     assert(sql("SHOW CATALOGS LIKE 'testcat*'").collect() === Array(
       Row("testcat"), Row("testcat2")))
+
+    assert(sql("SHOW CATALOGS LIKE 'TESTCAT*'").collect() === Array(
+      Row("testcat"), Row("testcat2")))
+
+    assert(sql("SHOW CATALOGS 'TESTCAT*'").collect() === Array(
+      Row("testcat"), Row("testcat2")))
+
+    assert(sql("SHOW CATALOGS 
'non_existing_catalog_pattern'").collect().isEmpty)
   }
 
   test("SPARK-49543: ShowCollations") {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to