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/10 04:29:35 UTC

[GitHub] [spark] amaliujia commented on a diff in pull request #38595: [SPARK-41090][SQL] Enhance Dataset.createTempView testing coverage for `db_name.view_name`

amaliujia commented on code in PR #38595:
URL: https://github.com/apache/spark/pull/38595#discussion_r1018641366


##########
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")
+      spark.catalog.tableExists("test_db.tempView")

Review Comment:
   Here is the case that I added.



-- 
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