You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2022/11/11 02:53:27 UTC

[GitHub] [spark] cloud-fan commented on a diff in pull request #38595: [SPARK-41090][SQL] Fix view not found issue for `db_name.view_name`

cloud-fan commented on code in PR #38595:
URL: https://github.com/apache/spark/pull/38595#discussion_r1019785842


##########
sql/core/src/test/scala/org/apache/spark/sql/DatasetSuite.scala:
##########
@@ -1135,21 +1135,27 @@ class DatasetSuite extends QueryTest
   }
 
   test("createTempView") {
-    val dataset = Seq(1, 2, 3).toDS()
-    dataset.createOrReplaceTempView("tempView")
-
-    // Overrides the existing temporary view with same name
-    // No exception should be thrown here.
-    dataset.createOrReplaceTempView("tempView")
-
-    // Throws AnalysisException if temp view with same name already exists
-    val e = intercept[AnalysisException](
-      dataset.createTempView("tempView"))
-    intercept[AnalysisException](dataset.createTempView("tempView"))
-    checkError(e,
-      errorClass = "TEMP_TABLE_OR_VIEW_ALREADY_EXISTS",
-      parameters = Map("relationName" -> "`tempView`"))
-    dataset.sparkSession.catalog.dropTempView("tempView")
+    withDatabase("test_db") {
+      val dataset = Seq(1, 2, 3).toDS()
+      dataset.createOrReplaceTempView("tempView")
+
+      // Overrides the existing temporary view with same name
+      // No exception should be thrown here.
+      dataset.createOrReplaceTempView("tempView")
+
+      // Throws AnalysisException if temp view with same name already exists
+      val e = intercept[AnalysisException](
+        dataset.createTempView("tempView"))
+      intercept[AnalysisException](dataset.createTempView("tempView"))
+      checkError(e,
+        errorClass = "TEMP_TABLE_OR_VIEW_ALREADY_EXISTS",
+        parameters = Map("relationName" -> "`tempView`"))
+      dataset.sparkSession.catalog.dropTempView("tempView")
+
+      spark.sql("CREATE DATABASE IF NOT EXISTS test_db")
+      dataset.createTempView("test_db.tempView")

Review Comment:
   local temp view can't have a database, the expected behavior should be failure 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: reviews-unsubscribe@spark.apache.org

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


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