dimas-b commented on code in PR #3360:
URL: https://github.com/apache/polaris/pull/3360#discussion_r2666038740


##########
runtime/service/src/main/java/org/apache/polaris/service/catalog/iceberg/IcebergCatalogHandler.java:
##########
@@ -1042,57 +1043,71 @@ public void commitTransaction(CommitTransactionRequest 
commitTransactionRequest)
         new TransactionWorkspaceMetaStoreManager(diagnostics, 
metaStoreManager);
     ((IcebergCatalog) 
baseCatalog).setMetaStoreManager(transactionMetaStoreManager);
 
-    commitTransactionRequest.tableChanges().stream()
-        .forEach(
-            change -> {
-              Table table = baseCatalog.loadTable(change.identifier());
-              if (!(table instanceof BaseTable baseTable)) {
-                throw new IllegalStateException(
-                    "Cannot wrap catalog that does not produce BaseTable");
-              }
-              if (isCreate(change)) {
-                throw new BadRequestException(
-                    "Unsupported operation: commitTranaction with 
updateForStagedCreate: %s",
-                    change);
-              }
+    // Group all changes by table identifier to handle them atomically
+    // This prevents conflicts when multiple changes target the same table 
entity
+    // LinkedHashMap preserves insertion order for deterministic processing
+    Map<TableIdentifier, List<UpdateTableRequest>> changesByTable = new 
LinkedHashMap<>();
+    for (UpdateTableRequest change : commitTransactionRequest.tableChanges()) {
+      if (isCreate(change)) {
+        throw new BadRequestException(
+            "Unsupported operation: commitTranaction with 
updateForStagedCreate: %s", change);
+      }
+      changesByTable.computeIfAbsent(change.identifier(), k -> new 
ArrayList<>()).add(change);

Review Comment:
   I'd rather not disable this in Polaris unless the spec explicitly flagged it 
as a disallowed use case (which it did not). 
   
   In lieu of an explicit spec, applying multiple updates in sequence is a 
fairly straight-forward operation since each update is self-contained and will 
be validated against the current metadata.



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