Skip to content

Commit 28fce4b

Browse files
committed
Removed: expire_snapshots_older_than method, in favor of implementing it in a separate issue.
Fixed: unrelated changes caused by afork/branch sync issues.
1 parent ce3515c commit 28fce4b

File tree

1 file changed

+3
-24
lines changed

1 file changed

+3
-24
lines changed

pyiceberg/table/update/snapshot.py

Lines changed: 3 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,6 @@
8888

8989

9090
from pyiceberg.table.metadata import Snapshot, TableMetadata
91-
from pyiceberg.table.snapshots import Snapshot
9291

9392

9493
def _new_manifest_file_name(num: int, commit_uuid: uuid.UUID) -> str:
@@ -244,7 +243,7 @@ def _summary(self, snapshot_properties: Dict[str, str] = EMPTY_DICT) -> Summary:
244243
previous_summary=previous_snapshot.summary if previous_snapshot is not None else None,
245244
)
246245

247-
def _commit(self, base_metadata: TableMetadata) -> UpdatesAndRequirements:
246+
def _commit(self) -> UpdatesAndRequirements:
248247
new_manifests = self._manifests()
249248
next_sequence_number = self._transaction.table_metadata.next_sequence_number()
250249

@@ -750,6 +749,7 @@ class ManageSnapshots(UpdateTableMetadata["ManageSnapshots"]):
750749
_requirements: Tuple[TableRequirement, ...] = ()
751750

752751
def _commit(self) -> UpdatesAndRequirements:
752+
"""Apply the pending changes and commit."""
753753
return self._updates, self._requirements
754754

755755
def _remove_ref_snapshot(self, ref_name: str) -> ManageSnapshots:
@@ -852,7 +852,7 @@ def remove_branch(self, branch_name: str) -> ManageSnapshots:
852852

853853
class ExpireSnapshots(UpdateTableMetadata["ExpireSnapshots"]):
854854
"""
855-
Expire snapshots by ID or by timestamp.
855+
Expire snapshots by ID.
856856
Use table.expire_snapshots().<operation>().commit() to run a specific operation.
857857
Use table.expire_snapshots().<operation-one>().<operation-two>().commit() to run multiple operations.
858858
Pending changes are applied on commit.
@@ -889,24 +889,3 @@ def expire_snapshot_by_id(self, snapshot_id: int) -> ExpireSnapshots:
889889
raise ValueError(f"Snapshot with ID {snapshot_id} does not exist.")
890890
self._snapshot_ids_to_expire.add(snapshot_id)
891891
return self
892-
893-
def expire_snapshots_older_than(self, timestamp_ms: int) -> ExpireSnapshots:
894-
"""
895-
Expire snapshots older than the given timestamp.
896-
897-
Args:
898-
timestamp_ms (int): The timestamp in milliseconds. Snapshots older than this will be expired.
899-
900-
Returns:
901-
This for method chaining.
902-
"""
903-
# Collect IDs of snapshots to be expired
904-
snapshots_to_remove = [
905-
snapshot.snapshot_id
906-
for snapshot in self._transaction.table_metadata.snapshots
907-
if snapshot.timestamp_ms < timestamp_ms
908-
]
909-
if snapshots_to_remove:
910-
for snapshot_id in snapshots_to_remove:
911-
self._snapshot_ids_to_expire.add(snapshot_id)
912-
return self

0 commit comments

Comments
 (0)