cloud-fan commented on a change in pull request #32832:
URL: https://github.com/apache/spark/pull/32832#discussion_r659609709



##########
File path: 
sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewSuite.scala
##########
@@ -910,4 +910,45 @@ abstract class SQLViewSuite extends QueryTest with 
SQLTestUtils {
       }
     }
   }
+
+  test("SPARK-35686: error out for creating view with auto gen alias") {
+    withView("v") {
+      val e = intercept[AnalysisException] {
+        sql("CREATE VIEW v AS SELECT count(*) FROM VALUES (1), (2), (3) t(a)")
+      }
+      assert(e.getMessage.contains("without explicitly assigning an alias"))
+      sql("CREATE VIEW v AS SELECT count(*) AS cnt FROM VALUES (1), (2), (3) 
t(a)")
+      checkAnswer(sql("SELECT * FROM v"), Seq(Row(3)))
+    }
+  }
+
+  test("SPARK-35686: error out for creating view with auto gen alias - nested 
type") {
+    withView("v") {
+      val e = intercept[AnalysisException] {
+        sql("CREATE VIEW v AS SELECT array(1, 2, 3)[0]")

Review comment:
       This is not a very interesting case. How about testing a real nested 
case like `SELECT * FROM (SELECT a + b ...)`?




-- 
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: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to