-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Convert list array and non-list array to scalars #7862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 4 commits
3472b51
d704c83
aee4eff
b92d535
3b6b53e
c69f874
f7b6ac0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -2039,7 +2039,11 @@ impl ScalarValue { | |||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||
| /// Retrieve ScalarValue for each row in `array` | ||||||||||||||||||||||||||
| /// Retrieve `ScalarValue` for each row in `array` | ||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||
| /// Convert `ListArray` to `Vec<Vec<ScalarValue>>`, first `Vec` is for rows, second `Vec` is for elements in the list | ||||||||||||||||||||||||||
|
||||||||||||||||||||||||||
| /// Convert `ListArray` to `Vec<Vec<ScalarValue>>`, first `Vec` is for rows, second `Vec` is for elements in the list | |
| /// Convert `ListArray` into a 2 dimensional to `Vec<Vec<ScalarValue>>`, first `Vec` is for rows, | |
| /// second `Vec` is for elements in the list. | |
| /// | |
| /// See [`Self::convert_non_list_array_to_scalars`] for converting non Lists | |
| /// | |
| /// This method is an optimization to unwrap nested ListArrays to nested Rust structures without | |
| /// converting them twice |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this would be easier to use if it didn't mix generic and non generic code
Maybe something like
| pub fn convert_list_array_to_scalar_vec<O: OffsetSizeTrait>( | |
| pub fn convert_list_array_to_scalar_vec( | |
| array: &dyn Array, | |
| ) -> Result<Vec<Vec<Self>>> { | |
| if let Some(arr) = array.as_list_opt::<i32> { | |
| Self::convert_list_array_to_scalar_vec_internal(arr) | |
| } else if let Some(arr) = array.as_list_opt::<64> { | |
| Self::convert_list_array_to_scalar_vec_internal(arr) | |
| } else { | |
| _internal_err!("Expected GenericListArray but found: {array:?}") | |
| } | |
| } |
And then internally pass in the cast Array by changing
fn convert_list_array_to_scalar_vec_internal<O: OffsetSizeTrait>(
array: &dyn Array,
) -> Result<Vec<Vec<Self>>> {
to
fn convert_list_array_to_scalar_vec_internal<O: OffsetSizeTrait>(
array: &GenericListArray<O>,
) -> Result<Vec<Vec<Self>>> {
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems left over