LB-Yu commented on code in PR #1509:
URL: https://github.com/apache/fluss/pull/1509#discussion_r2269224428
##########
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(
Review Comment:
I think we should check whether the property to be updated is the same as
the existing one, and if so, no changes are required.
--
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]