cloud-fan commented on a change in pull request #33219:
URL: https://github.com/apache/spark/pull/33219#discussion_r665854845
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/ShowCreateTableSuite.scala
##########
@@ -176,19 +177,32 @@ abstract class ShowCreateTableSuite extends QueryTest
with SQLTestUtils {
val createTable = "CREATE TABLE `t1` (`a` STRUCT<`b`: STRING>)"
sql(s"$createTable USING json")
val shownDDL = getShowDDL("SHOW CREATE TABLE t1")
- assert(shownDDL == "CREATE TABLE `default`.`t1` (`a` STRUCT<`b`:
STRING>)")
+ assert(shownDDL.mkString(" ") ==
+ "CREATE TABLE `default`.`t1` ( `a` STRUCT<`b`: STRING>) USING json")
checkCreateTable("t1")
}
}
- protected def getShowDDL(showCreateTableSql: String): String = {
- val result = sql(showCreateTableSql)
- .head()
- .getString(0)
- .split("\n")
- .map(_.trim)
- if (result.length > 1) result(0) + result(1) else result.head
+ test("SPARK-36012: Add NULL flag when SHOW CREATE TABLE") {
+ val t = "SPARK_36012"
+ withTable(t) {
+ sql(
+ s"""
+ |CREATE TABLE $t (
+ | a bigint NOT NULL,
+ | b bigint
+ |)
+ |USING ${classOf[SimpleInsertSource].getName}
+ """.stripMargin)
+ val showDDL = getShowDDL(s"SHOW CREATE TABLE $t")
+ assert(showDDL.mkString(" ") == s"CREATE TABLE `default`.`$t` ( `a`
BIGINT NOT NULL," +
+ s" `b` BIGINT) USING ${classOf[SimpleInsertSource].getName}")
+ }
+ }
+
+ protected def getShowDDL(showCreateTableSql: String): Array[String] = {
+ sql(showCreateTableSql).head().getString(0).split("\n").map(_.trim)
Review comment:
why can't we always call `.mkString(" ")` here?
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]