chinmay-bhat commented on code in PR #748: URL: https://github.com/apache/iceberg-python/pull/748#discussion_r1616717181
########## pyiceberg/table/__init__.py: ########## @@ -1290,6 +1291,19 @@ def snapshot_by_name(self, name: str) -> Optional[Snapshot]: return self.snapshot_by_id(ref.snapshot_id) return None + def latest_snapshot_before_timestamp(self, timestamp_ms: int) -> Optional[Snapshot]: + """Get the snapshot right before the given timestamp, or None if there is no matching snapshot.""" + result, prev_timestamp = None, 0 + if self.metadata.current_snapshot_id is not None: + for snapshot in self.current_ancestors(): + if snapshot and prev_timestamp < snapshot.timestamp_ms < timestamp_ms: + result, prev_timestamp = snapshot, snapshot.timestamp_ms + return result + + def current_ancestors(self) -> List[Optional[Snapshot]]: Review Comment: > Is there any use-case for this API that we may prefer a list? When we want to retrieve the snapshot_ids of ancestors, although the list is not needed, we can use Iterable too. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@iceberg.apache.org For additional commands, e-mail: issues-h...@iceberg.apache.org