Skip to content

Commit 254413f

Browse files
committed
Revert "use tbl.history() instead of ancestors_of()"
This reverts commit f5d489c.
1 parent 7f47b0d commit 254413f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

pyiceberg/table/__init__.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
SnapshotLogEntry,
114114
SnapshotSummaryCollector,
115115
Summary,
116+
ancestors_of,
116117
update_snapshot_summaries,
117118
)
118119
from pyiceberg.table.sorting import UNSORTED_SORT_ORDER, SortOrder
@@ -2027,7 +2028,10 @@ def rollback_to_snapshot(self, snapshot_id: int) -> ManageSnapshots:
20272028
self._commit_if_ref_updates_exist()
20282029
if self._transaction._table.snapshot_by_id(snapshot_id) is None:
20292030
raise ValidationError(f"Cannot roll back to unknown snapshot id: {snapshot_id}")
2030-
if snapshot_id not in {ancestor.snapshot_id for ancestor in self._transaction._table.history()}:
2031+
if snapshot_id not in {
2032+
ancestor.snapshot_id
2033+
for ancestor in ancestors_of(self._transaction._table.current_snapshot(), self._transaction.table_metadata)
2034+
}:
20312035
raise ValidationError(f"Cannot roll back to snapshot, not an ancestor of the current state: {snapshot_id}")
20322036

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

0 commit comments

Comments
 (0)