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



##########
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:
       Hey @YesOrNo828 , thanks for your suggestion!
   However, in the current design seems we [can not drop database that's not 
empty](https://github.com/apache/flink/blob/master/flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java#L435).
 Sorry I'm not very familiar with hive, do you think it's valid to have the 1-1 
mapping between 
[InvalidOperationException](https://hive.apache.org/javadocs/r2.1.1/api/org/apache/hadoop/hive/metastore/api/InvalidOperationException.html)
 and 
[DatabaseNotEmptyException](https://nightlies.apache.org/flink/flink-docs-release-1.10/api/java/org/apache/flink/table/catalog/exceptions/DatabaseNotEmptyException.html)?




-- 
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: issues-unsubscr...@flink.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to