github-actions[bot] commented on code in PR #69158:
URL: https://github.com/apache/doris/pull/69158#discussion_r4290406487


##########
fe/fe-connector/fe-connector-paimon/src/main/java/org/apache/doris/connector/paimon/PaimonSchemaPin.java:
##########
@@ -125,6 +126,29 @@ private static void validate(Table table, Map<String, 
String> pin, String path)
         }
     }
 
+    static FileStoreTable bindRestSchema(FileStoreTable table) {
+        if (table instanceof FallbackReadFileStoreTable) {
+            FallbackReadFileStoreTable pair = (FallbackReadFileStoreTable) 
table;
+            return PaimonTableDecorators.rebuildFallbackPair(pair,
+                    bindRestSchema(pair.wrapped()), 
bindRestSchema(pair.other()));
+        }
+        if (table instanceof DelegatedFileStoreTable) {
+            return PaimonTableDecorators.replaceWrapped(table,
+                    bindRestSchema(((DelegatedFileStoreTable) 
table).wrapped()));
+        }
+        TableSchema retained = table.schema();
+        TableSchema persisted = table.schemaManager().schema(retained.id());
+        // REST reconstructs TableSchema from Schema, synthesizing timeMillis, 
version and highestFieldId.
+        // Bind physical identity only on catalog load: rebinding a cached 
handle could adopt a replacement.
+        if (!retained.copy(Collections.emptyMap()).toSchema()
+                .equals(persisted.copy(Collections.emptyMap()).toSchema())) {
+            throw new DorisConnectorException("Paimon REST schema does not 
match stored schema "
+                    + retained.id() + "; retry the statement");
+        }
+        // Copy the schema on the existing table to preserve REST FileIO and 
catalog callbacks/options.
+        return table.copy(persisted.copy(retained.options()));

Review Comment:
   [P1] Keep REST metadata and physical schema in the same table generation. If 
a table is dropped/recreated at the same path after super.getTable() returns 
but before schema(retained.id()) reads the file, a replacement with the same 
schema ID/fields/keys/comment passes this comparison. This copy then combines 
the replacement's creation metadata with the old table's options. For example, 
primary keys (x,y) with bucket=2 can change bucket-key from x to y on 
recreation: later schema/snapshot pins all describe the replacement and pass, 
but WHERE x=k still prunes buckets using the old bucket-key=x, dropping 
matching replacement rows. REST snapshot reads are keyed by identifier, so 
retaining the old UUID does not fence this read. Establish that both reads 
refer to one generation (or reject/retry the load) before installing the 
physical identity, and cover replacement during binding; the current 
replacement test swaps files only after binding has completed.



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to