aboutsummaryrefslogtreecommitdiff
path: root/repl
diff options
context:
space:
mode:
authorDongjoon Hyun <dongjoon@apache.org>2016-07-15 00:51:11 +0800
committerCheng Lian <lian@databricks.com>2016-07-15 00:51:11 +0800
commitc576f9fb90853cce2e8e5dcc32a536a0f49cbbd8 (patch)
tree2c59d925bd5bf427b212a749c07c161b36798b6d /repl
parent12005c88fb24168d57b577cff73eddcd9d8963fc (diff)
downloadspark-c576f9fb90853cce2e8e5dcc32a536a0f49cbbd8.tar.gz
spark-c576f9fb90853cce2e8e5dcc32a536a0f49cbbd8.tar.bz2
spark-c576f9fb90853cce2e8e5dcc32a536a0f49cbbd8.zip
[SPARK-16529][SQL][TEST] `withTempDatabase` should set `default` database before dropping
## What changes were proposed in this pull request? `SQLTestUtils.withTempDatabase` is a frequently used test harness to setup a temporary table and clean up finally. This issue improves like the following for usability. ```scala - try f(dbName) finally spark.sql(s"DROP DATABASE $dbName CASCADE") + try f(dbName) finally { + if (spark.catalog.currentDatabase == dbName) { + spark.sql(s"USE ${DEFAULT_DATABASE}") + } + spark.sql(s"DROP DATABASE $dbName CASCADE") + } ``` In case of forgetting to reset the databaes, `withTempDatabase` will not raise Exception. ## How was this patch tested? This improves test harness. Author: Dongjoon Hyun <dongjoon@apache.org> Closes #14184 from dongjoon-hyun/SPARK-16529.
Diffstat (limited to 'repl')
0 files changed, 0 insertions, 0 deletions