alamb commented on code in PR #10005:
URL: https://github.com/apache/arrow-rs/pull/10005#discussion_r3283409701
##########
arrow-cast/src/cast/mod.rs:
##########
@@ -9038,6 +9038,41 @@ mod tests {
}
}
+ #[test]
+ fn test_cast_fixed_size_list_to_list_preserves_field_metadata() {
+ use std::collections::HashMap;
+
+ let metadata: HashMap<String, String> =
+ HashMap::from([("PARQUET:field_id".to_string(),
"89".to_string())]);
+
+ let src = Arc::new(
+ FixedSizeListArray::from_iter_primitive::<Float32Type, _, _>(
+ [[1.0_f32, 2.0].map(Some), [3.0, 4.0].map(Some)].map(Some),
+ 2,
+ ),
+ ) as ArrayRef;
+
+ let target_field = Arc::new(
+ Field::new("element", DataType::Float32,
true).with_metadata(metadata.clone()),
+ );
+
+ let target_types = [
+ DataType::List(target_field.clone()),
+ DataType::LargeList(target_field.clone()),
+ DataType::ListView(target_field.clone()),
+ DataType::LargeListView(target_field.clone()),
+ ];
+
+ for target_type in &target_types {
+ let result = cast(&src, target_type).unwrap();
+ assert_eq!(
+ result.data_type(),
Review Comment:
I verified this test covers the change by removing the code change and
running the test (it fails like this):
```
thread
'cast::tests::test_cast_fixed_size_list_to_list_preserves_field_metadata'
(76333843) panicked at arrow-cast/src/cast/mod.rs:9068:13:
assertion `left == right` failed: Cast to List(Field { name: "element",
data_type: Float32, nullable: true, metadata: {"PARQUET:field_id": "89"} })
should preserve field metadata
left: List(Field { data_type: Float32, nullable: true })
right: List(Field { name: "element", data_type: Float32, nullable: true,
metadata: {"PARQUET:field_id": "89"} })
failures:
cast::tests::test_cast_fixed_size_list_to_list_preserves_field_metadata
test result: FAILED. 341 passed; 1 failed; 0 ignored; 0 measured; 0 filtered
out; finished in 0.02s
```
--
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]