HyukjinKwon commented on a change in pull request #34719:
URL: https://github.com/apache/spark/pull/34719#discussion_r785579900
##########
File path:
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
##########
@@ -591,4 +605,52 @@ class PersistedViewTestSuite extends SQLViewTestSuite with
SharedSparkSession {
s" The view ${table.qualifiedName} may have been tampered with"))
}
}
+
+ test("show create table for persisted simple view") {
+ val viewName = "v1"
+ Seq(true, false).foreach { serde =>
+ withView(viewName) {
+ createView(viewName, "SELECT 1 AS a")
+ val expected = "CREATE VIEW `default`.`v1` ( `a`) AS SELECT 1 AS a"
+ assert(getShowCreateDDL(formattedViewName(viewName), serde) ==
expected)
+ }
+ }
+ }
+
+ test("show create table for persisted view with output columns") {
+ val viewName = "v1"
+ Seq(true, false).foreach { serde =>
+ withView(viewName) {
+ createView(viewName, "SELECT 1 AS a, 2 AS b", Seq("a", "b COMMENT 'b
column'"))
+ val expected = "CREATE VIEW `default`.`v1` ( `a`, `b` COMMENT 'b
column')" +
+ " AS SELECT 1 AS a, 2 AS b"
+ assert(getShowCreateDDL(formattedViewName(viewName), serde) ==
expected)
+ }
+ }
+ }
+
+ test("show create table for persisted simple view with table comment and
properties") {
+ val viewName = "v1"
+ Seq(true, false).foreach { serde =>
+ withView(viewName) {
+ createView(viewName, "SELECT 1 AS c1, '2' AS c2", Seq("c1 COMMENT
'bla'", "c2"),
+ Seq("COMMENT 'table comment'", "TBLPROPERTIES ( 'prop1' = 'value1',
'prop2' = 'value2')"))
+
+ val expected = "CREATE VIEW `default`.`v1` ( `c1` COMMENT 'bla',
`c2`)" +
+ " COMMENT 'table comment'" +
+ " TBLPROPERTIES ( 'prop1' = 'value1', 'prop2' = 'value2')" +
+ " AS SELECT 1 AS c1, '2' AS c2"
+ assert(getShowCreateDDL(formattedViewName(viewName), serde) ==
expected)
Review comment:
Hm, this test is flaky:
```
sbt.ForkMain$ForkError: org.scalatest.exceptions.TestFailedException:
"...BLPROPERTIES ( 'prop[2' = 'value2', 'prop1' = 'value1]') AS SELECT 1 AS
c1..." did not equal "...BLPROPERTIES ( 'prop[1' = 'value1', 'prop2' =
'value2]') AS SELECT 1 AS c1..."
at
org.scalatest.Assertions.newAssertionFailedException(Assertions.scala:472)
at
org.scalatest.Assertions.newAssertionFailedException$(Assertions.scala:471)
at
org.scalatest.Assertions$.newAssertionFailedException(Assertions.scala:1231)
at
org.scalatest.Assertions$AssertionsHelper.macroAssert(Assertions.scala:1295)
at
org.apache.spark.sql.execution.PersistedViewTestSuite.$anonfun$new$139(SQLViewTestSuite.scala:643)
at
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at org.apache.spark.util.Utils$.tryWithSafeFinally(Utils.scala:1475)
at
org.apache.spark.sql.test.SQLTestUtilsBase.withView(SQLTestUtils.scala:317)
at
org.apache.spark.sql.test.SQLTestUtilsBase.withView$(SQLTestUtils.scala:315)
at
org.apache.spark.sql.execution.SQLViewTestSuite.withView(SQLViewTestSuite.scala:37)
at
org.apache.spark.sql.execution.PersistedViewTestSuite.$anonfun$new$138(SQLViewTestSuite.scala:635)
at
org.apache.spark.sql.execution.PersistedViewTestSuite.$anonfun$new$138$adapted(SQLViewTestSuite.scala:634)
at scala.collection.immutable.List.foreach(List.scala:333)
at
org.apache.spark.sql.execution.PersistedViewTestSuite.$anonfun$new$137(SQLViewTestSuite.scala:634)
at
scala.runtime.java8.JFunction0$mcV$sp.apply(JFunction0$mcV$sp.scala:18)
at org.scalatest.OutcomeOf.outcomeOf(OutcomeOf.scala:85)
at org.scalatest.OutcomeOf.outcomeOf$(OutcomeOf.scala:83)
at org.scalatest.OutcomeOf$.outcomeOf(OutcomeOf.scala:104)
at org.scalatest.Transformer.apply(Transformer.scala:22)
at org.scalatest.Transformer.apply(Transformer.scala:20)
at
org.scalatest.funsuite.AnyFunSuiteLike$$anon$1.apply(AnyFunSuiteLike.scala:190)
at org.apache.spark.SparkFunSuite.withFixture(SparkFunSuite.scala:203)
at
org.scalatest.funsuite.AnyFunSuiteLike.invokeWithFixture$1(AnyFunSuiteLike.scala:188)
at
org.scalatest.funsuite.AnyFunSuiteLike.$anonfun$runTest$1(AnyFunSuiteLike.scala:200)
```
--
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]