Skip to content

Commit af78e52

Browse files
committed
refactor: rename expire_snapshot_by_id to by_id to align back with what original suggestions
1 parent c5ff202 commit af78e52

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

mkdocs/docs/api.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,16 +1344,16 @@ Expire old snapshots to clean up table metadata and reduce storage costs:
13441344

13451345
```python
13461346
# Basic usage - expire a specific snapshot by ID
1347-
table.maintenance.expire_snapshots().expire_snapshot_by_id(12345).commit()
1347+
table.maintenance.expire_snapshots().by_id(12345).commit()
13481348

13491349
# Context manager usage (recommended for multiple operations)
13501350
with table.maintenance.expire_snapshots() as expire:
1351-
expire.expire_snapshot_by_id(12345)
1352-
expire.expire_snapshot_by_id(67890)
1351+
expire.by_id(12345)
1352+
expire.by_id(67890)
13531353
# Automatically commits when exiting the context
13541354

13551355
# Method chaining
1356-
table.maintenance.expire_snapshots().expire_snapshot_by_id(12345).commit()
1356+
table.maintenance.expire_snapshots().by_id(12345).commit()
13571357
```
13581358

13591359
#### Real-world Example
@@ -1367,7 +1367,7 @@ def cleanup_old_snapshots(table_name: str, snapshot_ids: list[int]):
13671367
# Use context manager for safe transaction handling
13681368
with table.maintenance.expire_snapshots() as expire:
13691369
for snapshot_id in snapshot_ids:
1370-
expire.expire_snapshot_by_id(snapshot_id)
1370+
expire.by_id(snapshot_id)
13711371

13721372
print(f"Expired {len(snapshot_ids)} snapshots from {table_name}")
13731373

pyiceberg/table/update/snapshot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,7 +947,7 @@ def _get_protected_snapshot_ids(self) -> Set[int]:
947947

948948
return protected_ids
949949

950-
def expire_snapshot_by_id(self, snapshot_id: int) -> ExpireSnapshots:
950+
def by_id(self, snapshot_id: int) -> ExpireSnapshots:
951951
"""Expire a snapshot by its ID.
952952
953953
Args:

tests/table/test_maintenance_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def cleanup_old_snapshots(tbl: Table, snapshot_ids: list[int]) -> int:
153153
try:
154154
with tbl.maintenance.expire_snapshots() as expire:
155155
for snapshot_id in snapshot_ids:
156-
expire.expire_snapshot_by_id(snapshot_id)
156+
expire.by_id(snapshot_id)
157157
count += 1
158158
except (ValueError, NotImplementedError):
159159
# Expected for test scenarios

0 commit comments

Comments
 (0)