liamzwbao commented on code in PR #8354:
URL: https://github.com/apache/arrow-rs/pull/8354#discussion_r2870042661
##########
parquet-variant-compute/src/variant_get.rs:
##########
@@ -96,15 +184,44 @@ pub(crate) fn follow_shredded_path_element<'a>(
))
})?;
- let state = BorrowedShreddingState::try_from(struct_array)?;
+ let state = ShreddingState::try_from(struct_array)?;
Ok(ShreddedPathStep::Success(state))
}
- VariantPathElement::Index { .. } => {
- // TODO: Support array indexing. Among other things, it will
require slicing not
- // only the array we have here, but also the corresponding
metadata and null masks.
- Err(ArrowError::NotYetImplemented(
- "Pathing into shredded variant array index".into(),
- ))
+ VariantPathElement::Index { index } => {
+ let state = if let Some(list_array) =
+ typed_value.as_any().downcast_ref::<GenericListArray<i32>>()
+ {
+ take_list_like_index_as_shredding_state(list_array, *index,
cast_options)?
+ } else if let Some(list_array) =
+ typed_value.as_any().downcast_ref::<GenericListArray<i64>>()
+ {
+ take_list_like_index_as_shredding_state(list_array, *index,
cast_options)?
+ } else if let Some(list_view_array) = typed_value
+ .as_any()
+ .downcast_ref::<GenericListViewArray<i32>>()
+ {
+ take_list_like_index_as_shredding_state(list_view_array,
*index, cast_options)?
+ } else if let Some(list_view_array) = typed_value
+ .as_any()
+ .downcast_ref::<GenericListViewArray<i64>>()
+ {
+ take_list_like_index_as_shredding_state(list_view_array,
*index, cast_options)?
+ } else if cast_options.safe {
Review Comment:
Since we can inspect the type from `typed_value.data_type()`, maybe it is
better to match on that first and downcast only to the corresponding list type.
This avoids unnecessary downcast attempts. For example, `LargeListView` no
longer needs to try the first three list variants.
--
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]