YesOrNo828 commented on a change in pull request #17831:
URL: https://github.com/apache/flink/pull/17831#discussion_r756595287



##########
File path: 
flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -398,6 +398,34 @@ public void alterDatabase(
         }
     }
 
+    @Override
+    public void renameDatabase(
+            String databaseName, String newDatabaseName, boolean 
ignoreIfNotExists)
+            throws DatabaseNotExistException, DatabaseAlreadyExistException, 
CatalogException {
+        checkArgument(
+                !isNullOrWhitespaceOnly(databaseName), "databaseName cannot be 
null or empty");
+        checkArgument(
+                !isNullOrWhitespaceOnly(newDatabaseName),
+                "newDatabaseName cannot be null or empty");
+
+        try {
+            if (databaseExists(databaseName)) {
+                if (databaseExists(newDatabaseName)) {
+                    throw new DatabaseAlreadyExistException(getName(), 
newDatabaseName);
+                } else {
+                    Database database = getHiveDatabase(databaseName);
+                    database.setName(newDatabaseName);
+                    client.alterDatabase(databaseName, database);

Review comment:
       @shenzhu  you can set param `cascade = true`, when drop a not empty 
database by this 
[method](https://github.com/apache/flink/blob/master/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java#L426).




-- 
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