Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Revert "use tbl.history() instead of ancestors_of()"
This reverts commit f5d489c.
  • Loading branch information
chinmay-bhat committed Jul 2, 2024
commit 6859fa47c48c2c3bc890c861512d0cb20b9b9f5b
6 changes: 5 additions & 1 deletion pyiceberg/table/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
SnapshotLogEntry,
SnapshotSummaryCollector,
Summary,
ancestors_of,
update_snapshot_summaries,
)
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
Expand Down Expand Up @@ -2045,7 +2046,10 @@ def rollback_to_snapshot(self, snapshot_id: int) -> ManageSnapshots:
self._commit_if_ref_updates_exist()
if self._transaction._table.snapshot_by_id(snapshot_id) is None:
raise ValidationError(f"Cannot roll back to unknown snapshot id: {snapshot_id}")
if snapshot_id not in {ancestor.snapshot_id for ancestor in self._transaction._table.history()}:
if snapshot_id not in {
ancestor.snapshot_id
for ancestor in ancestors_of(self._transaction._table.current_snapshot(), self._transaction.table_metadata)
}:
raise ValidationError(f"Cannot roll back to snapshot, not an ancestor of the current state: {snapshot_id}")

update, requirement = self._transaction._set_ref_snapshot(snapshot_id=snapshot_id, ref_name="main", type="branch")
Expand Down