You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@spark.apache.org by we...@apache.org on 2022/01/05 16:04:53 UTC

[spark] branch master updated: [SPARK-33898][SQL][FOLLOWUP] Unify the v2 behavior with v1 for `SHOW CREATE TABLE` command

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 4741ecf  [SPARK-33898][SQL][FOLLOWUP] Unify the v2 behavior with v1 for `SHOW CREATE TABLE` command
4741ecf is described below

commit 4741ecfa8f95fefb0ef00ec757fd6bb265fb1c9f
Author: PengLei <pe...@gmail.com>
AuthorDate: Thu Jan 6 00:03:55 2022 +0800

    [SPARK-33898][SQL][FOLLOWUP] Unify the v2 behavior with v1 for `SHOW CREATE TABLE` command
    
    ### What changes were proposed in this pull request?
    1. Move the `SHOW CREATE TABLE w/ char/varchar` to `CharVarcharDDLTestBase`
    2. Fix the behavior different with v1 command that about the `TBLPROPERTIES`
    
    ### Why are the changes needed?
    Before the [#PR](https://github.com/apache/spark/pull/34719) merge. We should handle some different behavior or bugs between v1 and v2 command.
    
    ### Does this PR introduce _any_ user-facing change?
    No
    
    ### How was this patch tested?
    existed test case.
    
    Closes #34773 from Peng-Lei/v2-behavior-show-create-table.
    
    Authored-by: PengLei <pe...@gmail.com>
    Signed-off-by: Wenchen Fan <we...@databricks.com>
---
 .../sql/execution/datasources/v2/ShowCreateTableExec.scala     |  2 +-
 .../test/scala/org/apache/spark/sql/CharVarcharTestSuite.scala | 10 ----------
 .../org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala  |  2 +-
 .../spark/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 b2b90fb..5eaa169 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 f2df9af9..10eacdb 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 d7c9459..bc5a186 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
@@ -1903,7 +1903,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 0713e9b..f77b633 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 {

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