Skip to content

Commit 6859fa4

Browse files
committed
Revert "use tbl.history() instead of ancestors_of()"
This reverts commit f5d489c.
1 parent f7e192a commit 6859fa4

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
@@ -2045,7 +2046,10 @@ def rollback_to_snapshot(self, snapshot_id: int) -> ManageSnapshots:
20452046
self._commit_if_ref_updates_exist()
20462047
if self._transaction._table.snapshot_by_id(snapshot_id) is None:
20472048
raise ValidationError(f"Cannot roll back to unknown snapshot id: {snapshot_id}")
2048-
if snapshot_id not in {ancestor.snapshot_id for ancestor in self._transaction._table.history()}:
2049+
if snapshot_id not in {
2050+
ancestor.snapshot_id
2051+
for ancestor in ancestors_of(self._transaction._table.current_snapshot(), self._transaction.table_metadata)
2052+
}:
20492053
raise ValidationError(f"Cannot roll back to snapshot, not an ancestor of the current state: {snapshot_id}")
20502054

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

0 commit comments

Comments
 (0)