geruh commented on code in PR #2890:
URL: https://github.com/apache/iceberg-python/pull/2890#discussion_r2692867242


##########
pyiceberg/table/__init__.py:
##########
@@ -1491,9 +1492,22 @@ def refs(self) -> dict[str, SnapshotRef]:
         """Return the snapshot references in the table."""
         return self.metadata.refs
 
+    @staticmethod
+    def _check_uuid(current_metadata: TableMetadata, new_metadata: 
TableMetadata) -> None:
+        """Validate that the table UUID matches after refresh."""
+        current = current_metadata.table_uuid
+        refreshed = new_metadata.table_uuid
+
+        if current != refreshed:
+            raise ValueError(f"Table UUID does not match: current={current} != 
refreshed={refreshed}")
+
     def _do_commit(self, updates: tuple[TableUpdate, ...], requirements: 
tuple[TableRequirement, ...]) -> None:
         response = self.catalog.commit_table(self, requirements, updates)
 
+        # Check UUID to detect table replacement (matches Java's 
RESTTableOperations.updateCurrentMetadata)
+        if not isinstance(self, StagedTable):

Review Comment:
   This was here to mimick the behavior of `stageCreate` in the java 
implementation. But at the same time it seems safer to ensure that the uuid we 
assigned the table on create is returned back to us.



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