wuchong commented on code in PR #2416:
URL: https://github.com/apache/fluss/pull/2416#discussion_r2711847056


##########
fluss-common/src/main/java/org/apache/fluss/metadata/Schema.java:
##########
@@ -285,18 +285,21 @@ private Builder() {
 
         /** Adopts all members from the given schema. */
         public Builder fromSchema(Schema schema) {
-            columns.addAll(schema.columns);
-            if (schema.primaryKey != null) {
-                primaryKeyNamed(schema.primaryKey.constraintName, 
schema.primaryKey.columnNames);
-            }
-            if (schema.autoIncrementColumnNames != null
-                    && !schema.autoIncrementColumnNames.isEmpty()) {
-                checkState(
-                        schema.autoIncrementColumnNames.size() == 1,
-                        "Multiple auto increment columns are not supported 
yet.");
-                enableAutoIncrement(schema.autoIncrementColumnNames.get(0));
-            }
-            this.highestFieldId = new AtomicInteger(schema.highestFieldId);
+            // 1. Clear current builder state
+            this.columns.clear();
+            this.autoIncrementColumnNames.clear();
+            this.primaryKey = null;

Review Comment:
   I think it's better make sure the `fromSchema` is the first API to be called 
on the builder, rather than silently dropping previous columns. Otherwise, it's 
hard to debug the problem. You can validate all the members should be empty. 



-- 
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]

Reply via email to