liamzwbao commented on code in PR #9049:
URL: https://github.com/apache/arrow-rs/pull/9049#discussion_r2680646007
##########
parquet-variant-compute/src/variant_get.rs:
##########
@@ -4158,4 +4159,182 @@ mod test {
assert!(inner_values_result.is_null(1));
assert_eq!(inner_values_result.value(2), 333);
}
+
+ #[test]
+ fn test_variant_get_list_like_safe_cast() {
Review Comment:
Good idea, I will add some tests for `VariantPathElement::Field`.
For `shred_variant`, I think the following test covers the behavior in the
spec.
https://github.com/apache/arrow-rs/blob/802b8904f89ec2b2ed54076441a5bc15dbade858/parquet-variant-compute/src/shred_variant.rs#L1193-L1242
We can make some changes to the test to verify that the `value` would be an
array of `None` if the input is a perfectly shredded list array,
```rs
#[test]
fn test_array_shredding_as_list() {
let input = build_variant_array(vec![
VariantRow::List(vec![
VariantValue::from(1i64),
VariantValue::from(2i64),
VariantValue::from(3i64),
]),
VariantRow::List(vec![
VariantValue::from(1i64),
VariantValue::from(2i64),
VariantValue::from(3i64),
]),
VariantRow::List(vec![
VariantValue::from(1i64),
VariantValue::from(2i64),
VariantValue::from(3i64),
]),
VariantRow::List(vec![
VariantValue::from(1i64),
VariantValue::from(2i64),
VariantValue::from(3i64),
]),
]);
let list_schema = DataType::List(Arc::new(Field::new("item",
DataType::Int64, true)));
let result = shred_variant(&input, &list_schema).unwrap();
assert_eq!(result.len(), 4);
assert_list_structure_and_elements::<Int64Type, i32>(
&result,
4, // expected length
&[0, 3, 6, 9, 12], // expected offsets
&[Some(3), Some(3), Some(3), Some(3)], // expected sizes
&[None, None, None, None], // `value`
(
&[
Some(1),
Some(2),
Some(3),
Some(1),
Some(2),
Some(3),
Some(1),
Some(2),
Some(3),
Some(1),
Some(2),
Some(3),
], // `typed_values...typed_value`
&[
None, None, None, None, None, None, None, None, None,
None, None, None,
], // `typed_values...value`
), // `typed_value`
);
}
```
--
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]