dhruvarya-db commented on code in PR #3260:
URL: https://github.com/apache/iceberg-rust/pull/3260#discussion_r4128569473


##########
crates/iceberg/src/util/snapshot.rs:
##########
@@ -93,6 +122,76 @@ mod tests {
         std::sync::Arc::new(fixture.table.metadata().clone())
     }
 
+    type History = [(i64, i64)];
+
+    fn metadata_with_history(history: &History) -> TableMetadataRef {
+        let mut metadata = metadata().as_ref().clone();
+        metadata.snapshot_log = history
+            .iter()
+            .map(|&(timestamp_ms, snapshot_id)| SnapshotLog {
+                timestamp_ms,
+                snapshot_id,
+            })
+            .collect();
+        metadata.into()
+    }
+
+    #[test]
+    fn test_snapshot_id_as_of_time() {
+        let cases: &[(&History, i64, i64)] = &[
+            (&[(1000, S1), (2000, S2)], 1000, S1),
+            (&[(1000, S1), (2000, S2)], 1500, S1),
+            (&[(1000, S1), (2000, S2)], 2000, S2),
+            (&[(1000, S1), (2000, S2)], 3000, S2),
+            // Rollback records when an existing snapshot becomes current 
again.
+            (&[(1000, S1), (2000, S2), (3000, S1)], 3500, S1),
+            // The first equal maximum wins; max_by_key would pick S3.
+            (&[(1000, S1), (2000, S2), (2000, S3)], 2000, S2),
+            // Clock skew means the log need not be sorted by timestamp.
+            (&[(1000, S1), (3000, S2), (2500, S3)], 3500, S2),
+            (&[(1000, S1), (3000, S2), (2500, S3)], 2600, S3),
+            (&[(-2000, S1), (-1000, S2)], -1500, S1),
+            (&[(i64::MIN, S1), (0, S2)], i64::MIN, S1),

Review Comment:
   Added a short note to point out the difference with Java



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to