LB-Yu commented on code in PR #1509:
URL: https://github.com/apache/fluss/pull/1509#discussion_r2269091792
##########
fluss-server/src/main/java/com/alibaba/fluss/server/coordinator/MetadataManager.java:
##########
@@ -300,6 +303,65 @@ public long createTable(
"Fail to create table " + tablePath);
}
+ public void alterTable(
+ TablePath tablePath, TableDescriptor tableDescriptor, boolean
ignoreIfNotExists) {
+ // validate table properties before altering table
+ validateAlterTableProperties(tableDescriptor);
+
+ if (!databaseExists(tablePath.getDatabaseName())) {
+ throw new DatabaseNotExistException(
+ "Database " + tablePath.getDatabaseName() + " does not
exist.");
+ }
+ if (!tableExists(tablePath)) {
+ if (ignoreIfNotExists) {
+ return;
+ } else {
+ throw new TableNotExistException("Table " + tablePath + " does
not exists.");
+ }
+ }
+
+ try {
+ TableRegistration updatedTableRegistration =
+ getUpdatedTableRegistration(tablePath, tableDescriptor);
+ zookeeperClient.updateTable(tablePath, updatedTableRegistration);
+ } catch (Exception e) {
+ if (e instanceof KeeperException.NoNodeException) {
+ if (ignoreIfNotExists) {
+ return;
+ }
+ throw new TableNotExistException("Table " + tablePath + " does
not exists.");
+ } else {
+ throw new FlussRuntimeException("Failed to alter table: " +
tablePath, e);
+ }
+ }
+ }
+
+ private TableRegistration getUpdatedTableRegistration(
+ TablePath tablePath, TableDescriptor updateTableDescriptor) {
+ TableRegistration existTableReg = getTableRegistration(tablePath);
+ Map<String, String> updateProperties =
updateTableDescriptor.getProperties();
+ Map<String, String> updateCustomProperties =
updateTableDescriptor.getCustomProperties();
+ validateAlterTableProperties(updateTableDescriptor);
Review Comment:
Is this a duplicated validation?
--
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]