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

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


The following commit(s) were added to refs/heads/branch-4.x by this push:
     new 9c4491ef70e2 [SPARK-60583][SQL] Add golden tests for SHOW commands
9c4491ef70e2 is described below

commit 9c4491ef70e22bd548587b360b2191396e0a8718
Author: Vladan Vasić <[email protected]>
AuthorDate: Wed Oct 28 12:16:27 2026 +0000

    [SPARK-60583][SQL] Add golden tests for SHOW commands
    
    ### What changes were proposed in this pull request?
    
    Add one `show-commands.sql` input with execution-result and analyzed-plan 
goldens for:
    
    - `SHOW CATALOGS`: catalog loading, case-insensitive wildcard filtering and 
no matches.
    - `SHOW CURRENT NAMESPACE`: session catalog and V2 namespace state, an 
empty namespace,
      quoted multipart namespaces, and the `CURRENT DATABASE` / `CURRENT 
SCHEMA` aliases.
    - `SHOW COLLATIONS`: a bounded UTF8/ICU selection, an exact pattern without 
`LIKE`,
      and no matches.
    
    The input contains 11 SHOW scenarios plus setup and cleanup statements. No 
production
    code changes.
    
    ### Why are the changes needed?
    
    Tracks [SPARK-60583](https://issues.apache.org/jira/browse/SPARK-60583).
    
    Keep command outputs, output schemas and analyzed command nodes covered 
together in
    `SQLQueryTestSuite`. A small collation selection avoids snapshotting the 
entire ICU inventory.
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Regenerated both golden files with `SPARK_GENERATE_GOLDEN_FILES=1`, then 
reran without
    regeneration:
    
    ```bash
    build/sbt 'sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z 
show-commands.sql'
    ```
    
    Both `show-commands.sql` and `show-commands.sql_analyzer_test` passed (2 
tests, 0 failures).
    
    ### Was this patch authored or co-authored using generative AI tooling?
    
    Generated-by: OpenAI Codex CLI 0.164.0
    
    Closes #59835 from vladanvasi-db/vladanvasi-db/show-commands-golden-tests.
    
    Authored-by: Vladan Vasić <[email protected]>
    Signed-off-by: Uros Bojanic <[email protected]>
    (cherry picked from commit af255c000d29762d42a2d2de5510ad5f3da74953)
    Signed-off-by: Uros Bojanic <[email protected]>
---
 .../analyzer-results/show-commands.sql.out         | 120 ++++++++++++++++
 .../resources/sql-tests/inputs/show-commands.sql   |  26 ++++
 .../sql-tests/results/show-commands.sql.out        | 155 +++++++++++++++++++++
 3 files changed, 301 insertions(+)

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
new file mode 100644
index 000000000000..3b4d5ff84806
--- /dev/null
+++ 
b/sql/core/src/test/resources/sql-tests/analyzer-results/show-commands.sql.out
@@ -0,0 +1,120 @@
+-- Automatically generated by SQLQueryTestSuite
+-- !query
+SHOW CATALOGS
+-- !query analysis
+ShowCatalogsCommand
+
+
+-- !query
+SHOW CURRENT NAMESPACE
+-- !query analysis
+ShowCurrentNamespaceCommand
+
+
+-- !query
+CREATE DATABASE show_commands_db
+-- !query analysis
+CreateNamespace false
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [show_commands_db]
+
+
+-- !query
+USE show_commands_db
+-- !query analysis
+SetCatalogAndNamespace
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [show_commands_db]
+
+
+-- !query
+SHOW CURRENT DATABASE
+-- !query analysis
+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
+ShowCurrentNamespaceCommand
+
+
+-- !query
+USE spark_catalog.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
+DropNamespace false, false
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [show_commands_db]
+
+
+-- !query
+SHOW COLLATIONS LIKE 'utf8_*'
+-- !query analysis
+ShowCollationsCommand utf8_*
+
+
+-- !query
+SHOW COLLATIONS 'UTF8_BINARY'
+-- !query analysis
+ShowCollationsCommand UTF8_BINARY
+
+
+-- !query
+SHOW COLLATIONS LIKE 'non_existing_collation_pattern'
+-- !query analysis
+ShowCollationsCommand non_existing_collation_pattern
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
new file mode 100644
index 000000000000..59676ac79e14
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/inputs/show-commands.sql
@@ -0,0 +1,26 @@
+--SET 
spark.sql.catalog.testcat=org.apache.spark.sql.connector.catalog.InMemoryCatalog
+
+SHOW CATALOGS;
+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`;
+DROP DATABASE show_commands_db;
+
+SHOW COLLATIONS LIKE 'utf8_*';
+SHOW COLLATIONS 'UTF8_BINARY';
+SHOW COLLATIONS LIKE 'non_existing_collation_pattern';
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
new file mode 100644
index 000000000000..cb1b69ee0956
--- /dev/null
+++ b/sql/core/src/test/resources/sql-tests/results/show-commands.sql.out
@@ -0,0 +1,155 @@
+-- Automatically generated by SQLQueryTestSuite
+-- !query
+SHOW CATALOGS
+-- !query schema
+struct<catalog:string>
+-- !query output
+spark_catalog
+
+
+-- !query
+SHOW CURRENT NAMESPACE
+-- !query schema
+struct<catalog:string,namespace:string>
+-- !query output
+spark_catalog  default
+
+
+-- !query
+CREATE DATABASE show_commands_db
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+USE show_commands_db
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SHOW CURRENT DATABASE
+-- !query schema
+struct<catalog:string,namespace:string>
+-- !query output
+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
+
+
+
+-- !query
+DROP NAMESPACE testcat.show_commands_ns.`inner.ns`
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DROP DATABASE show_commands_db
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+SHOW COLLATIONS LIKE 'utf8_*'
+-- !query schema
+struct<NAME:string,LANGUAGE:string,COUNTRY:string,ACCENT_SENSITIVITY:string,CASE_SENSITIVITY:string,PAD_ATTRIBUTE:string,ICU_VERSION:string>
+-- !query output
+UTF8_BINARY    NULL    NULL    ACCENT_SENSITIVE        CASE_SENSITIVE  NO_PAD  
NULL
+UTF8_BINARY_RTRIM      NULL    NULL    ACCENT_SENSITIVE        CASE_SENSITIVE  
RTRIM   NULL
+UTF8_LCASE     NULL    NULL    ACCENT_SENSITIVE        CASE_INSENSITIVE        
NO_PAD  NULL
+UTF8_LCASE_RTRIM       NULL    NULL    ACCENT_SENSITIVE        
CASE_INSENSITIVE        RTRIM   NULL
+
+
+-- !query
+SHOW COLLATIONS 'UTF8_BINARY'
+-- !query schema
+struct<NAME:string,LANGUAGE:string,COUNTRY:string,ACCENT_SENSITIVITY:string,CASE_SENSITIVITY:string,PAD_ATTRIBUTE:string,ICU_VERSION:string>
+-- !query output
+UTF8_BINARY    NULL    NULL    ACCENT_SENSITIVE        CASE_SENSITIVE  NO_PAD  
NULL
+
+
+-- !query
+SHOW COLLATIONS LIKE 'non_existing_collation_pattern'
+-- !query schema
+struct<NAME:string,LANGUAGE:string,COUNTRY:string,ACCENT_SENSITIVITY:string,CASE_SENSITIVITY:string,PAD_ATTRIBUTE:string,ICU_VERSION:string>
+-- !query output
+


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

Reply via email to