Skip to content
Snippets Groups Projects
Commit d2dcd679 authored by Xiao Li's avatar Xiao Li
Browse files

[SPARK-20024][SQL][TEST-MAVEN] SessionCatalog reset need to set the current...

[SPARK-20024][SQL][TEST-MAVEN] SessionCatalog reset need to set the current database of ExternalCatalog

### What changes were proposed in this pull request?
SessionCatalog API setCurrentDatabase does not set the current database of the underlying ExternalCatalog. Thus, weird errors could come in the test suites after we call reset. We need to fix it.

So far, have not found the direct impact in the other code paths because we expect all the SessionCatalog APIs should always use the current database value we managed, unless some of code paths skip it. Thus, we fix it in the test-only function reset().

### How was this patch tested?
Multiple test case failures are observed in mvn and add a test case in SessionCatalogSuite.

Author: Xiao Li <gatorsmile@gmail.com>

Closes #17354 from gatorsmile/useDB.
parent 68d65fae
No related branches found
No related tags found
No related merge requests found
......@@ -1175,6 +1175,7 @@ class SessionCatalog(
*/
def reset(): Unit = synchronized {
setCurrentDatabase(DEFAULT_DATABASE)
externalCatalog.setCurrentDatabase(DEFAULT_DATABASE)
listDatabases().filter(_ != DEFAULT_DATABASE).foreach { db =>
dropDatabase(db, ignoreIfNotExists = false, cascade = true)
}
......
......@@ -53,7 +53,6 @@ abstract class SessionCatalogSuite extends PlanTest {
private def withBasicCatalog(f: SessionCatalog => Unit): Unit = {
val catalog = new SessionCatalog(newBasicCatalog())
catalog.createDatabase(newDb("default"), ignoreIfExists = true)
try {
f(catalog)
} finally {
......@@ -76,7 +75,6 @@ abstract class SessionCatalogSuite extends PlanTest {
test("basic create and list databases") {
withEmptyCatalog { catalog =>
catalog.createDatabase(newDb("default"), ignoreIfExists = true)
assert(catalog.databaseExists("default"))
assert(!catalog.databaseExists("testing"))
assert(!catalog.databaseExists("testing2"))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment