This is an automated email from the ASF dual-hosted git repository.
wenchen pushed a commit to branch branch-3.1
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.1 by this push:
new b30e0a1 [SPARK-34770][SQL] InMemoryCatalog.tableExists should not
fail if database doesn't exist
b30e0a1 is described below
commit b30e0a1138146e5ef22c9a7b78a2543b434ed315
Author: Wenchen Fan <[email protected]>
AuthorDate: Wed Mar 17 16:36:50 2021 +0800
[SPARK-34770][SQL] InMemoryCatalog.tableExists should not fail if database
doesn't exist
This PR updates `InMemoryCatalog.tableExists` to return false if database
doesn't exist, instead of failing. The new behavior is consistent with
`HiveExternalCatalog` which is used in production, so this bug mostly only
affects tests.
bug fix
no
a new test
Closes #31860 from cloud-fan/catalog.
Authored-by: Wenchen Fan <[email protected]>
Signed-off-by: Wenchen Fan <[email protected]>
(cherry picked from commit 1a4971d8a16b5bc624cef584271243bf64a51941)
Signed-off-by: Wenchen Fan <[email protected]>
---
.../scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala | 3 +--
.../org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala | 3 +++
.../test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala | 2 --
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
index 90e6946..08b54fc 100644
---
a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
+++
b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/InMemoryCatalog.scala
@@ -342,8 +342,7 @@ class InMemoryCatalog(
}
override def tableExists(db: String, table: String): Boolean = synchronized {
- requireDbExists(db)
- catalog(db).tables.contains(table)
+ catalog.contains(db) && catalog(db).tables.contains(table)
}
override def listTables(db: String): Seq[String] = synchronized {
diff --git
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
index 98f9ce6..ad996db 100644
---
a/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
+++
b/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala
@@ -691,6 +691,9 @@ abstract class SessionCatalogSuite extends AnalysisTest
with Eventually {
catalog.createTempView("tbl3", tempTable, overrideIfExists = false)
// tableExists should not check temp view.
assert(!catalog.tableExists(TableIdentifier("tbl3")))
+
+ // If database doesn't exist, return false instead of failing.
+ assert(!catalog.tableExists(TableIdentifier("tbl1", Some("non-exist"))))
}
}
diff --git
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
index 52aa6d82..cf5ef63 100644
---
a/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
+++
b/sql/core/src/test/scala/org/apache/spark/sql/execution/SQLViewTestSuite.scala
@@ -295,8 +295,6 @@ abstract class SQLViewTestSuite extends QueryTest with
SQLTestUtils {
}
test("SPARK-34504: drop an invalid view") {
- // TODO: fix dropping non-existing global temp views.
- assume(viewTypeString != "GLOBAL TEMPORARY VIEW")
withTable("t") {
sql("CREATE TABLE t(s STRUCT<i: INT, j: INT>) USING json")
val viewName = createView("v", "SELECT s.i FROM t")
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]