lawofcycles commented on code in PR #3320:
URL: https://github.com/apache/iceberg-python/pull/3320#discussion_r3608097400
##########
pyiceberg/table/update/snapshot.py:
##########
@@ -91,19 +97,50 @@ def _new_manifest_list_file_name(snapshot_id: int, attempt:
int, commit_uuid: uu
return f"snap-{snapshot_id}-{attempt}-{commit_uuid}.avro"
+@dataclass(frozen=True)
+class CommitWindow:
+ """Tracks the commit range to validate against during retry.
+
+ base: The snapshot when the operation began (exclusive lower bound, fixed
across retries).
+ head: The branch HEAD snapshot after metadata refresh (inclusive upper
bound).
+ """
+
+ base: Snapshot | None
+ head: Snapshot | None
+
+ @classmethod
+ def resolve(cls, metadata: TableMetadata, base_id: int | None, branch: str
| None) -> CommitWindow:
+ """Resolve a CommitWindow from metadata, starting snapshot ID, and
target branch."""
+ head = metadata.snapshot_by_name(branch)
+ base = metadata.snapshot_by_id(base_id) if base_id is not None else
None
+ if base_id is not None and base is None:
+ raise ValidationException(f"Cannot find starting snapshot
{base_id}")
+ return cls(base=base, head=head)
+
+ def is_empty(self) -> bool:
Review Comment:
Good catch. A None base now triggers full-history validation instead of
skipping, matching Java's treatment of a null starting snapshot.
`_validation_history` and the added-file lookups now accept a None lower bound
and walk every ancestor of the head. Added your test as a regression.
--
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]