sdf-jkl commented on code in PR #8201:
URL: https://github.com/apache/arrow-rs/pull/8201#discussion_r2294712496
##########
parquet-variant-compute/src/cast_to_variant.rs:
##########
@@ -535,6 +535,88 @@ pub fn cast_to_variant(input: &dyn Array) ->
Result<VariantArray, ArrowError> {
builder.append_variant(value);
}
}
+ DataType::List(_) => {
+ let list_array = input.as_list::<i32>();
+ let values = list_array.values();
+ let offsets = list_array.offsets();
+
+ let first_offset = offsets.first().expect("There should be an
offset");
+ let length = offsets.last().expect("There should be an offset") -
first_offset;
+ let sliced_values = values.slice(*first_offset as usize, length as
usize);
+
+ let values_variant_array =
cast_to_variant(sliced_values.as_ref())?;
+ let new_offsets = OffsetBuffer::new(ScalarBuffer::from_iter(
+ offsets.iter().map(|o| o - first_offset),
+ ));
Review Comment:
I implemented the optimization you mentioned above like this.
I also added a test for sliced list arrays.
--
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]