Skip to content

Commit f158ae9

Browse files
committed
rename api to latest_snapshot_before_timestamp
1 parent 7f87949 commit f158ae9

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

pyiceberg/table/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1290,9 +1290,9 @@ def snapshot_by_name(self, name: str) -> Optional[Snapshot]:
12901290
return self.snapshot_by_id(ref.snapshot_id)
12911291
return None
12921292

1293-
def snapshot_by_timestamp(self, timestamp_ms: int) -> Optional[Snapshot]:
1293+
def latest_snapshot_before_timestamp(self, timestamp_ms: int) -> Optional[Snapshot]:
12941294
"""Get the snapshot right before the given timestamp, or None if there is no matching snapshot."""
1295-
return self.metadata.snapshot_by_timestamp(timestamp_ms)
1295+
return self.metadata.latest_snapshot_before_timestamp(timestamp_ms)
12961296

12971297
def history(self) -> List[SnapshotLogEntry]:
12981298
"""Get the snapshot history of this table."""

pyiceberg/table/metadata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def snapshot_by_id(self, snapshot_id: int) -> Optional[Snapshot]:
230230
"""Get the snapshot by snapshot_id."""
231231
return next((snapshot for snapshot in self.snapshots if snapshot.snapshot_id == snapshot_id), None)
232232

233-
def snapshot_by_timestamp(self, timestamp_ms: int) -> Optional[Snapshot]:
233+
def latest_snapshot_before_timestamp(self, timestamp_ms: int) -> Optional[Snapshot]:
234234
"""Get the snapshot right before the given timestamp."""
235235
result, prev_timestamp = None, 0
236236
for snapshot in self.snapshots:

tests/table/test_init.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ def test_snapshot_by_id(table_v2: Table) -> None:
205205

206206

207207
def test_snapshot_by_timestamp(table_v2: Table) -> None:
208-
assert table_v2.snapshot_by_timestamp(1555100955771) == Snapshot(
208+
assert table_v2.latest_snapshot_before_timestamp(1555100955771) == Snapshot(
209209
snapshot_id=3055729675574597004,
210210
parent_snapshot_id=3051729675574597004,
211211
sequence_number=1,

0 commit comments

Comments
 (0)