You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by GitBox <gi...@apache.org> on 2019/06/19 09:23:24 UTC
[GitHub] [flink] lirui-apache commented on a change in pull request #8786:
[FLINK-12877][table][hive] Unify catalog database implementations
lirui-apache commented on a change in pull request #8786: [FLINK-12877][table][hive] Unify catalog database implementations
URL: https://github.com/apache/flink/pull/8786#discussion_r295196243
##########
File path: flink-connectors/flink-connector-hive/src/main/java/org/apache/flink/table/catalog/hive/HiveCatalog.java
##########
@@ -228,32 +246,30 @@ public void alterDatabase(String databaseName, CatalogDatabase newDatabase, bool
checkArgument(!StringUtils.isNullOrWhitespaceOnly(databaseName), "databaseName cannot be null or empty");
checkNotNull(newDatabase, "newDatabase cannot be null");
- CatalogDatabase existingDatabase;
- try {
- existingDatabase = getDatabase(databaseName);
- } catch (DatabaseNotExistException e) {
- if (!ignoreIfNotExists) {
- throw e;
- }
- return;
- }
-
- if (existingDatabase.getClass() != newDatabase.getClass()) {
- throw new CatalogException(
- String.format("Database types don't match. Existing database is '%s' and new database is '%s'.",
- existingDatabase.getClass().getName(), newDatabase.getClass().getName())
- );
- }
-
Database newHiveDatabase = instantiateHiveDatabase(databaseName, newDatabase);
try {
+ CatalogDatabase existingDatabase = getDatabase(databaseName);
+ validateAlterDatabase(existingDatabase.getProperties(), newDatabase.getProperties());
client.alterDatabase(databaseName, newHiveDatabase);
+ } catch (DatabaseNotExistException e) {
+ if (!ignoreIfNotExists) {
+ throw new DatabaseNotExistException(getName(), databaseName);
+ }
} catch (TException e) {
throw new CatalogException(String.format("Failed to alter database %s", databaseName), e);
}
}
+ private static void validateAlterDatabase(Map<String, String> oldProp, Map<String, String> newProp) {
+ for (String immutable : IMMUTABLE_DATABASE_PROPERTIES) {
Review comment:
Shall we also verify old DB and new DB are of same type?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services