geruh commented on code in PR #2890:
URL: https://github.com/apache/iceberg-python/pull/2890#discussion_r2684788635
##########
pyiceberg/table/__init__.py:
##########
@@ -1491,9 +1492,21 @@ def refs(self) -> dict[str, SnapshotRef]:
"""Return the snapshot references in the table."""
return self.metadata.refs
+ def _check_uuid(self, new_metadata: TableMetadata) -> None:
+ """Validate that the table UUID matches after refresh or commit."""
+ current = self.metadata.table_uuid
+ refreshed = new_metadata.table_uuid
+
+ if current and refreshed and 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)
+ # Only check UUID for existing tables, not new tables
+ if not isinstance(self, StagedTable):
+ self._check_uuid(response.metadata)
+
Review Comment:
Thanks for the review @Fokko and @kevinjqliu!
I was following the behavior of both implementations while REST is explicit
about the check the BaseMetastore operations says eventually check. That being
said, I can't think of a scenario where the commit check would catch something
that Assert Table check wouldn't. So the commit check is purely defensive.
--
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]