yaooqinn commented on a change in pull request #32931:
URL: https://github.com/apache/spark/pull/32931#discussion_r656942472
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/connector/DataSourceV2SQLSuite.scala
##########
@@ -1961,12 +1961,98 @@ class DataSourceV2SQLSuite
}
}
- test("SHOW CREATE TABLE") {
+ test("SHOW CREATE TABLE AS SERDE") {
val t = "testcat.ns1.ns2.tbl"
withTable(t) {
spark.sql(s"CREATE TABLE $t (id bigint, data string) USING foo")
- testNotSupportedV2Command("SHOW CREATE TABLE", t)
- testNotSupportedV2Command("SHOW CREATE TABLE", s"$t AS SERDE")
+ val e = intercept[AnalysisException] {
+ sql(s"SHOW CREATE TABLE $t AS SERDE")
+ }
+ assert(e.message.contains(s"SHOW CREATE TABLE AS SERDE is not supported
for v2 tables."))
+ }
+ }
+
+ test("SPARK-33898: SHOW CREATE TABLE") {
+ val t = "testcat.ns1.ns2.tbl"
+ withTable(t) {
+ spark.sql( s"""CREATE TABLE $t (
+ | a bigint,
+ | b bigint,
+ | c bigint,
+ | `extra col` ARRAY<INT>,
+ | `<another>` STRUCT<x: INT, y: ARRAY<BOOLEAN>>
+ |)
+ |USING foo
+ |OPTIONS (
+ | from = 0,
+ | to = 1)
+ |COMMENT 'This is a comment'
+ |TBLPROPERTIES ('prop1' = '1')
+ |PARTITIONED BY (a)
+ |LOCATION '/tmp'
+ """.stripMargin)
+ val showDDL = getShowCreateDDL(s"SHOW CREATE TABLE $t")
+ assert(showDDL === Array(
+ "CREATE TABLE testcat.ns1.ns2.tbl (",
+ "`a` BIGINT,",
+ "`b` BIGINT,",
+ "`c` BIGINT,",
+ "`extra col` ARRAY<INT>,",
+ "`<another>` STRUCT<`x`: INT, `y`: ARRAY<BOOLEAN>>)",
+ "USING foo",
+ "OPTIONS(",
+ "'from' = '0',",
+ "'to' = '1')",
+ "PARTITIONED BY (a)",
+ "COMMENT 'This is a comment'",
+ "LOCATION '/tmp'",
+ "TBLPROPERTIES(",
+ "'prop1' = '1')"
+ ))
+ }
+ }
+
+ test("SPARK-33898: SHOW CREATE TABLE WITH AS SELECT") {
+ val t = "testcat.ns1.ns2.tbl"
+ withTable(t) {
+ spark.sql( s"""CREATE TABLE $t
Review comment:
ditto, spaces
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]