Skip to content

Commit 0526e5d

Browse files
committed
display UTF8_BINARY default collation and add tests
1 parent 13eeb10 commit 0526e5d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

sql/core/src/main/scala/org/apache/spark/sql/execution/command/DescribeRelationJsonCommand.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,9 @@ case class DescribeRelationJsonCommand(
289289
filteredTableInfo.map { case (key, value) =>
290290
addKeyValueToMap(key, value, jsonMap)
291291
}
292+
// Add default collation if not yet added (addKeyValueToMap only adds unique keys).
293+
// Add here to only affect `DESC AS JSON` and not the `DESC TABLE` output.
294+
addKeyValueToMap("collation", JString("UTF8_BINARY"), jsonMap)
292295
}
293296

294297
private def describePartitionInfoJson(

sql/core/src/test/scala/org/apache/spark/sql/execution/command/v1/DescribeTableSuite.scala

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
273273
last_access = Some("UNKNOWN"),
274274
created_by = Some(s"Spark $SPARK_VERSION"),
275275
`type` = Some("MANAGED"),
276+
collation = Some("UTF8_BINARY"),
276277
provider = Some("parquet"),
277278
bucket_columns = Some(List("employee_id")),
278279
sort_columns = Some(List("employee_name")),
@@ -338,6 +339,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
338339
last_access = Some("UNKNOWN"),
339340
created_by = Some(s"Spark $SPARK_VERSION"),
340341
`type` = Some("MANAGED"),
342+
collation = Some("UTF8_BINARY"),
341343
provider = Some("parquet"),
342344
bucket_columns = Some(Nil),
343345
sort_columns = Some(Nil),
@@ -402,6 +404,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
402404
last_access = Some("UNKNOWN"),
403405
created_by = Some(s"Spark $SPARK_VERSION"),
404406
`type` = Some("MANAGED"),
407+
collation = Some("UTF8_BINARY"),
405408
provider = Some("parquet"),
406409
bucket_columns = Some(Nil),
407410
sort_columns = Some(Nil),
@@ -437,7 +440,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
437440
| id INT
438441
|)
439442
|USING parquet COMMENT 'table_comment'
440-
|DEFAULT COLLATION UTF8_BINARY
443+
|DEFAULT COLLATION DE
441444
|""".stripMargin
442445
spark.sql(tableCreationStr)
443446

@@ -460,7 +463,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
460463
last_access = Some("UNKNOWN"),
461464
created_by = Some(s"Spark $SPARK_VERSION"),
462465
`type` = Some("MANAGED"),
463-
collation = Some("UTF8_BINARY"),
466+
collation = Some("DE"),
464467
storage_properties = None,
465468
provider = Some("parquet"),
466469
bucket_columns = Some(Nil),
@@ -514,6 +517,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
514517
last_access = Some("UNKNOWN"),
515518
created_by = Some(s"Spark $SPARK_VERSION"),
516519
`type` = Some("MANAGED"),
520+
collation = Some("UTF8_BINARY"),
517521
storage_properties = None,
518522
provider = Some("parquet"),
519523
bucket_columns = Some(Nil),
@@ -569,6 +573,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
569573
last_access = Some("UNKNOWN"),
570574
created_by = Some(s"Spark $SPARK_VERSION"),
571575
`type` = Some("VIEW"),
576+
collation = Some("UTF8_BINARY"),
572577
view_text = Some("SELECT * FROM spark_catalog.ns.table"),
573578
view_original_text = if (isTemp) None else Some("SELECT * FROM spark_catalog.ns.table"),
574579
// TODO: this is unexpected and temp view should also use COMPENSATION mode.
@@ -760,6 +765,7 @@ trait DescribeTableSuiteBase extends command.DescribeTableSuiteBase
760765
last_access = Some("UNKNOWN"),
761766
created_by = Some(s"Spark $SPARK_VERSION"),
762767
`type` = Some("MANAGED"),
768+
collation = Some("UTF8_BINARY"),
763769
provider = Some("parquet"),
764770
comment = Some("A table with nested complex types"),
765771
table_properties = Some(Map(

0 commit comments

Comments
 (0)