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

wenchen 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 958c1abda64d [SPARK-52710][SQL] `DESCRIBE SCHEMA` should print 
collation
958c1abda64d is described below

commit 958c1abda64d897a8ccc912153a1ad66a25e8bdd
Author: ilicmarkodb <marko.i...@databricks.com>
AuthorDate: Wed Jul 9 10:26:40 2025 +0800

    [SPARK-52710][SQL] `DESCRIBE SCHEMA` should print collation
    
    ### What changes were proposed in this pull request?
    Extended `DescribeDatabaseCommand` to print collation.
    
    ### Why are the changes needed?
    Part of new feature.
    
    ### Does this PR introduce _any_ user-facing change?
    No.
    
    ### How was this patch tested?
    Updated `describe.sql`.
    
    ### Was this patch authored or co-authored using generative AI tooling?
    No.
    
    Closes #51401 from ilicmarkodb/fix_describe_schema.
    
    Authored-by: ilicmarkodb <marko.i...@databricks.com>
    Signed-off-by: Wenchen Fan <wenc...@databricks.com>
---
 .../apache/spark/sql/execution/command/ddl.scala   |  5 ++-
 .../sql-tests/analyzer-results/describe.sql.out    | 35 +++++++++++++++
 .../test/resources/sql-tests/inputs/describe.sql   |  7 +++
 .../resources/sql-tests/results/describe.sql.out   | 52 ++++++++++++++++++++++
 .../org/apache/spark/sql/SQLQueryTestSuite.scala   |  1 +
 5 files changed, 98 insertions(+), 2 deletions(-)

diff --git 
a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala 
b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
index 13994c58f120..d76d8cf1cb71 100644
--- a/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
+++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/command/ddl.scala
@@ -189,8 +189,9 @@ case class DescribeDatabaseCommand(
       Row("Catalog Name", SESSION_CATALOG_NAME) ::
         Row("Database Name", dbMetadata.name) ::
         Row("Comment", dbMetadata.description) ::
-        Row("Location", CatalogUtils.URIToString(dbMetadata.locationUri))::
-        Row("Owner", allDbProperties.getOrElse(PROP_OWNER, "")) :: Nil
+        Row("Location", CatalogUtils.URIToString(dbMetadata.locationUri)) ::
+        Row("Owner", allDbProperties.getOrElse(PROP_OWNER, "")) ::
+        allDbProperties.get(PROP_COLLATION).map(Row("Collation", _)).toList
 
     if (extended) {
       val properties = allDbProperties -- 
CatalogV2Util.NAMESPACE_RESERVED_PROPERTIES
diff --git 
a/sql/core/src/test/resources/sql-tests/analyzer-results/describe.sql.out 
b/sql/core/src/test/resources/sql-tests/analyzer-results/describe.sql.out
index 2f7237663b64..e49673d33943 100644
--- a/sql/core/src/test/resources/sql-tests/analyzer-results/describe.sql.out
+++ b/sql/core/src/test/resources/sql-tests/analyzer-results/describe.sql.out
@@ -213,6 +213,41 @@ org.apache.spark.sql.catalyst.parser.ParseException
 }
 
 
+-- !query
+DROP SCHEMA IF EXISTS test_schema
+-- !query analysis
+DropNamespace true, false
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [test_schema]
+
+
+-- !query
+CREATE SCHEMA test_schema DEFAULT COLLATION UNICODE
+-- !query analysis
+CreateNamespace false, [collation=UNICODE]
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [test_schema]
+
+
+-- !query
+DESCRIBE SCHEMA EXTENDED test_schema
+-- !query analysis
+DescribeNamespace true, [info_name#x, info_value#x]
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [test_schema]
+
+
+-- !query
+ALTER SCHEMA test_schema DEFAULT COLLATION UTF8_LCASE
+-- !query analysis
+SetNamespaceCollationCommand UTF8_LCASE
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [test_schema]
+
+
+-- !query
+DESCRIBE SCHEMA EXTENDED test_schema
+-- !query analysis
+DescribeNamespace true, [info_name#x, info_value#x]
++- ResolvedNamespace V2SessionCatalog(spark_catalog), [test_schema]
+
+
 -- !query
 DESC temp_v
 -- !query analysis
diff --git a/sql/core/src/test/resources/sql-tests/inputs/describe.sql 
b/sql/core/src/test/resources/sql-tests/inputs/describe.sql
index dbe5bc840bce..2b4191a28250 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/describe.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/describe.sql
@@ -64,6 +64,13 @@ DESC t PARTITION (c='Us');
 -- ParseException: PARTITION specification is incomplete
 DESC t PARTITION (c='Us', d);
 
+-- DESC SCHEMA
+DROP SCHEMA IF EXISTS test_schema;
+CREATE SCHEMA test_schema DEFAULT COLLATION UNICODE;
+DESCRIBE SCHEMA EXTENDED test_schema;
+ALTER SCHEMA test_schema DEFAULT COLLATION UTF8_LCASE;
+DESCRIBE SCHEMA EXTENDED test_schema;
+
 -- DESC Temp View
 
 DESC temp_v;
diff --git a/sql/core/src/test/resources/sql-tests/results/describe.sql.out 
b/sql/core/src/test/resources/sql-tests/results/describe.sql.out
index 3659267e8e9f..989672c94285 100644
--- a/sql/core/src/test/resources/sql-tests/results/describe.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/describe.sql.out
@@ -453,6 +453,58 @@ org.apache.spark.sql.catalyst.parser.ParseException
 }
 
 
+-- !query
+DROP SCHEMA IF EXISTS test_schema
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+CREATE SCHEMA test_schema DEFAULT COLLATION UNICODE
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DESCRIBE SCHEMA EXTENDED test_schema
+-- !query schema
+struct<info_name:string,info_value:string>
+-- !query output
+Catalog Name   spark_catalog
+Collation      UNICODE
+Comment        
+Location [not included in comparison]/{warehouse_dir}/test_schema.db
+Namespace Name test_schema
+Owner  [not included in comparison]
+Properties
+
+
+-- !query
+ALTER SCHEMA test_schema DEFAULT COLLATION UTF8_LCASE
+-- !query schema
+struct<>
+-- !query output
+
+
+
+-- !query
+DESCRIBE SCHEMA EXTENDED test_schema
+-- !query schema
+struct<info_name:string,info_value:string>
+-- !query output
+Catalog Name   spark_catalog
+Collation      UTF8_LCASE
+Comment        
+Location [not included in comparison]/{warehouse_dir}/test_schema.db
+Namespace Name test_schema
+Owner  [not included in comparison]
+Properties
+
+
 -- !query
 DESC temp_v
 -- !query schema
diff --git 
a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala 
b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
index e4fe46d08fa7..6a7dd9c7c892 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/SQLQueryTestSuite.scala
@@ -156,6 +156,7 @@ class SQLQueryTestSuite extends QueryTest with 
SharedSparkSession with SQLHelper
     // SPARK-39564: don't print out serde to avoid introducing complicated and 
error-prone
     // regex magic.
     .set("spark.test.noSerdeInExplain", "true")
+    .set(SQLConf.SCHEMA_LEVEL_COLLATIONS_ENABLED, true)
 
   // SPARK-32106 Since we add SQL test 'transform.sql' will use `cat` command,
   // here we need to ignore it.


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org
For additional commands, e-mail: commits-h...@spark.apache.org

Reply via email to