pub fn snapshot_id_as_of_time(
table_metadata: &TableMetadataRef,
timestamp_ms: i64,
) -> Result<i64>Expand description
Resolve the snapshot ID from the main-history entry with the greatest timestamp
at or before timestamp_ms (milliseconds since the Unix epoch), taking the first
entry on ties.
This matches Java’s ordering, except that an entry at i64::MIN can match here
but never matches in Java, which seeds its search with Long.MIN_VALUE.
PyIceberg takes the last qualifying log entry, so ties or out-of-order
timestamps can produce different results.
Returns ErrorKind::DataInvalid if no matching history exists.
The returned snapshot may have expired, so
snapshot_by_id can still return None.
use iceberg::util::snapshot::snapshot_id_as_of_time;
let metadata = table.metadata();
// The snapshot log has entries at 1515100955770 and 1555100955770.
let snapshot_id = snapshot_id_as_of_time(&metadata, 1_555_100_955_770)?;
assert_eq!(snapshot_id, 3055729675574597004);
assert!(snapshot_id_as_of_time(&metadata, 1_515_100_955_769).is_err());