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: [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]

Reply via email to