JosephLenton commented on code in PR #2916:
URL: https://github.com/apache/iceberg-rust/pull/2916#discussion_r4612441614
##########
crates/iceberg/src/spec/manifest/writer.rs:
##########
@@ -1058,4 +1071,184 @@ mod tests {
"content_size_in_bytes",
]);
}
+
+ #[tokio::test]
+ async fn test_manifest_v1_roundtrips_uuid_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::uuid(
+ uuid::Uuid::from_u128(0xf79c3e09_677c_4bbd_a479_3f349cb785e7),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v1,
+ Type::Primitive(PrimitiveType::Uuid),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
+
+ #[tokio::test]
+ async fn test_manifest_v2_roundtrips_uuid_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::uuid(
+ uuid::Uuid::from_u128(0xf79c3e09_677c_4bbd_a479_3f349cb785e7),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v2_data,
+ Type::Primitive(PrimitiveType::Uuid),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
+
+ #[tokio::test]
+ async fn test_manifest_v3_roundtrips_uuid_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::uuid(
+ uuid::Uuid::from_u128(0xf79c3e09_677c_4bbd_a479_3f349cb785e7),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v3_data,
+ Type::Primitive(PrimitiveType::Uuid),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
+
+ #[tokio::test]
+ async fn test_manifest_v1_roundtrips_16_byte_fixed_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::fixed(
+ 0xf79c3e09_677c_4bbd_a479_3f349cb785e7_u128.to_be_bytes(),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v1,
+ Type::Primitive(PrimitiveType::Fixed(16)),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
+
+ #[tokio::test]
+ async fn test_manifest_v2_roundtrips_16_byte_fixed_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::fixed(
+ 0xf79c3e09_677c_4bbd_a479_3f349cb785e7_u128.to_be_bytes(),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v2_data,
+ Type::Primitive(PrimitiveType::Fixed(16)),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
+
+ #[tokio::test]
+ async fn test_manifest_v3_roundtrips_16_byte_fixed_partition() {
+ let data_file = DataFileBuilder::default()
+ .content(DataContentType::Data)
+ .file_path("memory:///table/data/00000.parquet".to_string())
+ .file_format(DataFileFormat::Parquet)
+ .partition(Struct::from_iter([Some(Literal::fixed(
+ 0xf79c3e09_677c_4bbd_a479_3f349cb785e7_u128.to_be_bytes(),
+ ))]))
+ .record_count(123)
+ .file_size_in_bytes(456)
+ .build()
+ .unwrap();
+
+ let output = write_and_read_data_file(
+ ManifestWriterBuilder::build_v3_data,
+ Type::Primitive(PrimitiveType::Fixed(16)),
+ data_file.clone(),
+ )
+ .await;
+
+ assert_eq!(output, data_file);
+ }
Review Comment:
I've refactored these tests to a single one, which covers `cases x
manifest_version_types`.
That includes a `["null", "uuid_fixed"]` test case.
--
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]