Repository: spark Updated Branches: refs/heads/master 68d65fae7 -> d2dcd6792
[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 <gatorsm...@gmail.com> Closes #17354 from gatorsmile/useDB. Project: http://git-wip-us.apache.org/repos/asf/spark/repo Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/d2dcd679 Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/d2dcd679 Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/d2dcd679 Branch: refs/heads/master Commit: d2dcd6792f4cea39e12945ad8c4cda5d8d034de4 Parents: 68d65fa Author: Xiao Li <gatorsm...@gmail.com> Authored: Mon Mar 20 22:52:45 2017 -0700 Committer: Xiao Li <gatorsm...@gmail.com> Committed: Mon Mar 20 22:52:45 2017 -0700 ---------------------------------------------------------------------- .../org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala | 1 + .../apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala | 2 -- 2 files changed, 1 insertion(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/spark/blob/d2dcd679/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala ---------------------------------------------------------------------- diff --git a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala index 25aa8d3..b134fd4 100644 --- a/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala +++ b/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalog.scala @@ -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) } http://git-wip-us.apache.org/repos/asf/spark/blob/d2dcd679/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/catalog/SessionCatalogSuite.scala ---------------------------------------------------------------------- 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 bb87763..fd9e5d6 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 @@ -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")) --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@spark.apache.org For additional commands, e-mail: commits-h...@spark.apache.org