From aa3bc5b799f62ccec5f85f2ee6a2515fad196b7c Mon Sep 17 00:00:00 2001 From: PengLei Date: Wed, 1 Dec 2021 16:55:41 +0800 Subject: [PATCH] add draft --- .../execution/datasources/v2/ShowCreateTableExec.scala | 2 +- .../org/apache/spark/sql/CharVarcharTestSuite.scala | 10 ---------- .../spark/sql/connector/DataSourceV2SQLSuite.scala | 2 +- .../sql/execution/command/CharVarcharDDLTestBase.scala | 9 +++++++++ 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowCreateTableExec.scala b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowCreateTableExec.scala index b2b90fbcff15c..5eaa16961886b 100644 --- a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowCreateTableExec.scala +++ b/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/v2/ShowCreateTableExec.scala @@ -109,7 +109,7 @@ case class ShowCreateTableExec( s"'${escapeSingleQuotedString(key)}' = '${escapeSingleQuotedString(value)}'" } - builder ++= "TBLPROPERTIES" + builder ++= "TBLPROPERTIES " builder ++= concatByMultiLines(props) } } diff --git a/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala index f2df9af9ed8ef..10eacdb08c424 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala @@ -843,16 +843,6 @@ class FileSourceCharVarcharTestSuite extends CharVarcharTestSuite with SharedSpa } } - // TODO(SPARK-33898): Move these tests to super after SHOW CREATE TABLE for v2 implemented - test("SPARK-33892: SHOW CREATE TABLE w/ char/varchar") { - withTable("t") { - sql(s"CREATE TABLE t(v VARCHAR(3), c CHAR(5)) USING $format") - val rest = sql("SHOW CREATE TABLE t").head().getString(0) - assert(rest.contains("VARCHAR(3)")) - assert(rest.contains("CHAR(5)")) - } - } - test("SPARK-34114: should not trim right for read-side length check and char padding") { Seq("char", "varchar").foreach { typ => withTempPath { dir => 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 949abfeefc267..1f03976d4c12c 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 @@ -2031,7 +2031,7 @@ class DataSourceV2SQLSuite "PARTITIONED BY (a)", "COMMENT 'This is a comment'", "LOCATION 'file:/tmp'", - "TBLPROPERTIES(", + "TBLPROPERTIES (", "'prop1' = '1',", "'prop2' = '2',", "'prop3' = '3',", diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CharVarcharDDLTestBase.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CharVarcharDDLTestBase.scala index 0713e9be3f5e4..f77b6336b81c0 100644 --- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CharVarcharDDLTestBase.scala +++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/CharVarcharDDLTestBase.scala @@ -160,6 +160,15 @@ trait CharVarcharDDLTestBase extends QueryTest with SQLTestUtils { Row("char(5)")) } } + + test("SPARK-33892: SHOW CREATE TABLE w/ char/varchar") { + withTable("t") { + sql(s"CREATE TABLE t(v VARCHAR(3), c CHAR(5)) USING $format") + val rest = sql("SHOW CREATE TABLE t").head().getString(0) + assert(rest.contains("VARCHAR(3)")) + assert(rest.contains("CHAR(5)")) + } + } } class FileSourceCharVarcharDDLTestSuite extends CharVarcharDDLTestBase with SharedSparkSession {