aboutsummaryrefslogtreecommitdiff
path: root/sql/core/src/test
diff options
context:
space:
mode:
authorDongjoon Hyun <dongjoon@apache.org>2016-07-11 15:15:47 +0200
committerHerman van Hovell <hvanhovell@databricks.com>2016-07-11 15:15:47 +0200
commit7ac79da0e4607f7f89a3617edf53c2b174b378e8 (patch)
tree45945e49be9c406a8bbfc935f439d14098be9dbc /sql/core/src/test
parent9cb1eb7af779e74165552977002158a7dad9bb09 (diff)
downloadspark-7ac79da0e4607f7f89a3617edf53c2b174b378e8.tar.gz
spark-7ac79da0e4607f7f89a3617edf53c2b174b378e8.tar.bz2
spark-7ac79da0e4607f7f89a3617edf53c2b174b378e8.zip
[SPARK-16459][SQL] Prevent dropping current database
## What changes were proposed in this pull request? This PR prevents dropping the current database to avoid errors like the followings. ```scala scala> sql("create database delete_db") scala> sql("use delete_db") scala> sql("drop database delete_db") scala> sql("create table t as select 1") org.apache.spark.sql.catalyst.analysis.NoSuchDatabaseException: Database `delete_db` not found; ``` ## How was this patch tested? Pass the Jenkins tests including an updated testcase. Author: Dongjoon Hyun <dongjoon@apache.org> Closes #14115 from dongjoon-hyun/SPARK-16459.
Diffstat (limited to 'sql/core/src/test')
-rw-r--r--sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala9
1 files changed, 9 insertions, 0 deletions
diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
index 7d1f1d1e62..b4294ed7ff 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/command/DDLSuite.scala
@@ -1270,6 +1270,15 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
"WITH SERDEPROPERTIES ('spark.sql.sources.me'='anything')")
}
+ test("drop current database") {
+ sql("CREATE DATABASE temp")
+ sql("USE temp")
+ val m = intercept[AnalysisException] {
+ sql("DROP DATABASE temp")
+ }.getMessage
+ assert(m.contains("Can not drop current database `temp`"))
+ }
+
test("drop default database") {
Seq("true", "false").foreach { caseSensitive =>
withSQLConf(SQLConf.CASE_SENSITIVE.key -> caseSensitive) {