loserwang1024 commented on code in PR #2189:
URL: https://github.com/apache/fluss/pull/2189#discussion_r2625453318
##########
fluss-server/src/main/java/org/apache/fluss/server/coordinator/MetadataManager.java:
##########
@@ -322,24 +322,26 @@ public long createTable(
}
public void alterTableSchema(
- TablePath tablePath, List<TableChange> schemaChanges, boolean
ignoreIfNotExists)
+ TablePath tablePath,
+ List<TableChange> schemaChanges,
+ boolean ignoreIfNotExists,
+ @Nullable LakeCatalog lakeCatalog,
+ LakeCatalog.Context lakeCatalogContext)
throws TableNotExistException, TableNotPartitionedException {
try {
TableInfo table = getTable(tablePath);
- // TODO: remote this after lake enable table support schema
evolution, track by
- // https://github.com/apache/fluss/issues/2128
- if (table.getTableConfig().isDataLakeEnabled()) {
- throw new InvalidAlterTableException(
- "Schema evolution is currently not supported for
tables with datalake enabled.");
- }
-
// validate the table column changes
if (!schemaChanges.isEmpty()) {
Schema newSchema = SchemaUpdate.applySchemaChanges(table,
schemaChanges);
- // update the schema
- zookeeperClient.registerSchema(tablePath, newSchema,
table.getSchemaId() + 1);
+ // update the schema in Fluss (ZK) first - Fluss is the source
of truth
+ if (!newSchema.equals(table.getSchema())) {
Review Comment:
My adive is:
1. check that fluss can apply schema change.
SchemaUpdate.applySchemaChanges(table, schemaChanges)
2. Check whether the schema can be apply to lake.
3. zookeeperClient.registerSchema(tablePath, newSchema, table.getSchemaId()
+ 1). This can be rarely happen because only zookeeper.
4. syncSchemaChangesToLake.
Also a problem left is what if zookeeperClient.registerSchema success but
syncSchemaChangesToLake fails? The The addColumn return user will fail result
but the schema is applied successfully. How to resyncSchemaChangesToLake?
Maybe we can add column(but ignore if last columns are already same coumns.)
@wuchong , WDYT?
--
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]