fsk119 commented on code in PR #23501:
URL: https://github.com/apache/flink/pull/23501#discussion_r1354785270


##########
flink-table/flink-table-planner/src/test/scala/org/apache/flink/table/planner/catalog/CatalogTableITCase.scala:
##########
@@ -1271,6 +1271,13 @@ class CatalogTableITCase(isStreamingMode: Boolean) 
extends AbstractTestBase {
         |)
       """.stripMargin
     tableEnv.executeSql(ddl2)
+    try {

Review Comment:
   Do like this
   ```
   assertThatThrownBy(() => tableEnv.executeSql("drop database db1")).satisfies(
         anyCauseMatches(
           classOf[ValidationException],
           "Cannot drop a database which is currently in" +
             " use."))
   ```



##########
flink-table/flink-table-api-java/src/main/java/org/apache/flink/table/catalog/CatalogManager.java:
##########
@@ -1404,6 +1405,10 @@ public void createDatabase(
     public void dropDatabase(
             String catalogName, String databaseName, boolean 
ignoreIfNotExists, boolean cascade)
             throws DatabaseNotExistException, DatabaseNotEmptyException, 
CatalogException {
+        if (Objects.equals(currentCatalogName, catalogName)
+                && Objects.equals(currentDatabaseName, databaseName)) {
+            throw new CatalogException("Cannot drop a database which is 
currently in use.");

Review Comment:
   It's better to throw ValidationException here.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to