File tree Expand file tree Collapse file tree 3 files changed +12
-12
lines changed
catalyst/src/main/scala/org/apache/spark/sql/catalyst/catalog
core/src/test/scala/org/apache/spark/sql/execution/command
hive/src/test/scala/org/apache/spark/sql/hive/execution Expand file tree Collapse file tree 3 files changed +12
-12
lines changed Original file line number Diff line number Diff line change @@ -148,8 +148,10 @@ class SessionCatalog(
148
148
149
149
def dropDatabase (db : String , ignoreIfNotExists : Boolean , cascade : Boolean ): Unit = {
150
150
val dbName = formatDatabaseName(db)
151
- if (dbName == DEFAULT_DATABASE || dbName == getCurrentDatabase) {
152
- throw new AnalysisException (s " Can not drop ` ${DEFAULT_DATABASE }` or current database " )
151
+ if (dbName == DEFAULT_DATABASE ) {
152
+ throw new AnalysisException (s " Can not drop default database " )
153
+ } else if (dbName == getCurrentDatabase) {
154
+ throw new AnalysisException (s " Can not drop current database ` ${dbName}` " )
153
155
}
154
156
externalCatalog.dropDatabase(dbName, ignoreIfNotExists, cascade)
155
157
}
Original file line number Diff line number Diff line change @@ -1270,28 +1270,30 @@ class DDLSuite extends QueryTest with SharedSQLContext with BeforeAndAfterEach {
1270
1270
" WITH SERDEPROPERTIES ('spark.sql.sources.me'='anything')" )
1271
1271
}
1272
1272
1273
- test(" drop default or current database" ) {
1273
+ test(" drop current database" ) {
1274
1274
sql(" CREATE DATABASE temp" )
1275
1275
sql(" USE temp" )
1276
1276
val m = intercept[AnalysisException ] {
1277
1277
sql(" DROP DATABASE temp" )
1278
1278
}.getMessage
1279
- assert(m.contains(" Can not drop `default` or current database" ))
1279
+ assert(m.contains(" Can not drop current database `temp`" ))
1280
+ }
1280
1281
1282
+ test(" drop default database" ) {
1281
1283
Seq (" true" , " false" ).foreach { caseSensitive =>
1282
1284
withSQLConf(SQLConf .CASE_SENSITIVE .key -> caseSensitive) {
1283
1285
var message = intercept[AnalysisException ] {
1284
1286
sql(" DROP DATABASE default" )
1285
1287
}.getMessage
1286
- assert(message.contains(" Can not drop ` default` or current database" ))
1288
+ assert(message.contains(" Can not drop default database" ))
1287
1289
1288
1290
message = intercept[AnalysisException ] {
1289
1291
sql(" DROP DATABASE DeFault" )
1290
1292
}.getMessage
1291
1293
if (caseSensitive == " true" ) {
1292
1294
assert(message.contains(" Database 'DeFault' not found" ))
1293
1295
} else {
1294
- assert(message.contains(" Can not drop ` default` or current database" ))
1296
+ assert(message.contains(" Can not drop default database" ))
1295
1297
}
1296
1298
}
1297
1299
}
Original file line number Diff line number Diff line change @@ -567,18 +567,14 @@ class HiveDDLSuite
567
567
var message = intercept[AnalysisException ] {
568
568
sql(" DROP DATABASE default" )
569
569
}.getMessage
570
- assert(message.contains(" Can not drop ` default` or current database" ))
570
+ assert(message.contains(" Can not drop default database" ))
571
571
572
572
// SQLConf.CASE_SENSITIVE does not affect the result
573
573
// because the Hive metastore is not case sensitive.
574
574
message = intercept[AnalysisException ] {
575
575
sql(" DROP DATABASE DeFault" )
576
576
}.getMessage
577
- if (caseSensitive == " true" ) {
578
- assert(message.contains(" Can not drop default database" ))
579
- } else {
580
- assert(message.contains(" Can not drop `default` or current database" ))
581
- }
577
+ assert(message.contains(" Can not drop default database" ))
582
578
}
583
579
}
584
580
}
You can’t perform that action at this time.
0 commit comments