c-thiel commented on code in PR #3693:
URL: https://github.com/apache/iceberg-rust/pull/3693#discussion_r4578353573
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -3375,6 +3368,67 @@ mod tests {
assert_eq!(desered_type.current_schema_id(), 0);
}
+ fn v1_main_ref() -> (String, SnapshotReference) {
+ let retention = SnapshotRetention::branch(None, None, None);
+ (
+ "main".to_string(),
+ SnapshotReference::new(6278926806555018392, retention),
+ )
+ }
+
+ #[test]
+ fn test_table_metadata_v1_refs_round_trip() {
Review Comment:
[09d294f](https://github.com/apache/iceberg-rust/pull/3693/commits/09d294f8aa6e3c9af16fffd39a722b371fd669d0)
##########
crates/iceberg/src/spec/table_metadata.rs:
##########
@@ -3375,6 +3368,67 @@ mod tests {
assert_eq!(desered_type.current_schema_id(), 0);
}
+ fn v1_main_ref() -> (String, SnapshotReference) {
+ let retention = SnapshotRetention::branch(None, None, None);
+ (
+ "main".to_string(),
+ SnapshotReference::new(6278926806555018392, retention),
+ )
+ }
+
+ #[test]
+ fn test_table_metadata_v1_refs_round_trip() {
+ // Written by Spark 3.5.6 with Iceberg 1.9.2, paths rewritten.
+ let json =
+
fs::read_to_string("testdata/table_metadata/TableMetadataV1WithRefs.json").unwrap();
+ let metadata: TableMetadata = serde_json::from_str(&json).unwrap();
+
+ assert_eq!(metadata.format_version(), FormatVersion::V1);
+ assert_eq!(
+ metadata.refs,
+ HashMap::from_iter([
+ v1_main_ref(),
+ (
+ "t1".to_string(),
+ SnapshotReference::new(7825560978372493301,
SnapshotRetention::Tag {
+ max_ref_age_ms: Some(604800000),
+ }),
+ ),
+ (
+ "b1".to_string(),
+ SnapshotReference::new(
+ 7825560978372493301,
+ SnapshotRetention::branch(Some(2), None, None),
+ ),
+ ),
+ ])
+ );
+
+ let written = serde_json::to_value(&metadata).unwrap();
+ let java_written =
serde_json::from_str::<serde_json::Value>(&json).unwrap();
+ assert_eq!(written["format-version"], 1);
+ assert_eq!(written["refs"], java_written["refs"]);
+ assert_eq!(
+ serde_json::from_value::<TableMetadata>(written).unwrap(),
+ metadata
+ );
+ }
+
+ #[test]
+ fn test_table_metadata_v1_without_refs_has_main_branch() {
Review Comment:
[09d294f](https://github.com/apache/iceberg-rust/pull/3693/commits/09d294f8aa6e3c9af16fffd39a722b371fd669d0)
--
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]