[SPARK-34770][SQL] InMemoryCatalog.tableExists should not fail if database doesn't exist
### What changes were proposed in this pull request? 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. ### Why are the changes needed? bug fix ### Does this PR introduce _any_ user-facing change? no ### How was this patch tested? a new test Closes #31860 from cloud-fan/catalog. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This commit is contained in:
parent
115f777cb0
commit
1a4971d8a1
|
@ -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 {
|
||||
|
|
|
@ -704,6 +704,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"))))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue