karubian commented on code in PR #3635:
URL: https://github.com/apache/iceberg-rust/pull/3635#discussion_r4538785840
##########
crates/iceberg/src/spec/manifest/metadata.rs:
##########
@@ -132,3 +132,42 @@ impl ManifestMetadata {
&self.content
}
}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ fn metadata_without_schema_id(format_version: &str) -> HashMap<String,
Vec<u8>> {
+ HashMap::from([
+ (
+ "schema".to_string(),
+ br#"{"type":"struct","schema-id":3,"fields":[]}"#.to_vec(),
+ ),
+ ("partition-spec".to_string(), b"[]".to_vec()),
+ ("partition-spec-id".to_string(), b"0".to_vec()),
+ (
+ "format-version".to_string(),
+ format_version.as_bytes().to_vec(),
+ ),
+ ("content".to_string(), b"data".to_vec()),
+ ])
+ }
+
+ #[test]
+ fn test_parse_takes_schema_id_from_schema_when_key_is_missing() {
+ for format_version in ["1", "2", "3"] {
+ let metadata =
+
ManifestMetadata::parse(&metadata_without_schema_id(format_version)).unwrap();
+
+ assert_eq!(metadata.schema_id(), 3);
+ }
+ }
Review Comment:
Good point, done. Both tests now build one v2 header, with `content`.
--
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]