amaliujia commented on code in PR #38595:
URL: https://github.com/apache/spark/pull/38595#discussion_r1019834165
##########
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:
Choose to throw when DB name presents.
Waiting for test job to see if there is existing test case that needs an
update.
--
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]