Uh oh!
There was an error while loading. Please reload this page.
Convert list array and non-list array to scalars - #7862
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
e7fd4ca to
c9f4ea1CompareSummary of changes
|
alamb
commented
Oct 30, 2023
I think this is not waiting on any more feedback |
4b780ea to
49a671fCompareUh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
542226d to
6b56441Comparejayzhan211
commented
Nov 28, 2023
wait on #8253 |
d17a682 to
29ac936Comparejayzhan211
commented
Dec 9, 2023
wait on #8439 |
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
29ac936 to
aee4effCompareUh oh!
There was an error while loading. Please reload this page.
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
jayzhan211
commented
Dec 16, 2023
@alamb I think this is ready to go, thanks |
alamb
left a comment
There was a problem hiding this comment.
Thank you @jayzhan211 -- this is looking quite close I think
| /// 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 |
There was a problem hiding this comment.
👍 It might also help to explain why we need two different signatures. It took me a while to grok things too
| /// 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 |
| /// Retrieve `ScalarValue` for each row in `array` | ||
| /// |
There was a problem hiding this comment.
This seems left over
| /// Retrieve `ScalarValue` for each row in `array` | |
| /// |
| /// ``` | ||
| pub fn convert_array_to_scalar_vec(array: &dyn Array) -> Result<Vec<Vec<Self>>> { | ||
| let mut scalars = Vec::with_capacity(array.len()); | ||
| pub fn convert_list_array_to_scalar_vec<O: OffsetSizeTrait>( |
There was a problem hiding this comment.
I think this would be easier to use if it didn't mix generic and non generic code
Maybe something like
| pubfn convert_list_array_to_scalar_vec<O:OffsetSizeTrait>( | |
| pubfn convert_list_array_to_scalar_vec( | |
| array:&dyn Array, | |
| ) -> Result<Vec<Vec<Self>>> { | |
| ifletSome(arr) = array.as_list_opt::<i32>{ | |
| Self::convert_list_array_to_scalar_vec_internal(arr) | |
| }elseifletSome(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>>> {
Signed-off-by: jayzhan211 <jayzhan211@gmail.com>
(BTW sorry for being so nit picky on this PR -- I think |
This comment is a bit too late... And, this API is actually not breaking the previous one Anyway, this change is just improvement, not fixing a critical error, so I will close it. |
alamb
commented
Dec 18, 2023
I am sorry -- I feel really bad that we can't find more review bandwidth to match your contributions @jayzhan211 -- your efforts so far have been great and are really appreciated. |
Which issue does this PR close?
Closes #.
Rationale for this change
convert_array_to_scalar_veccan convert well for list array, but we will getVec<Vec<ScalarValue>>for non-list array (primitive array).It would be nice to have another conversion that returns nicely
Vec<ScalarValue>for the non-list array. I would need this for #7835 too.What changes are included in this PR?
convert_list_array_to_scalar_vecfor ListArrayconvert_non_list_array_to_scalar_vecfor non-ListArrayThe nested array for DistinctArrayAggAccumulator (update_batch) is removed so as to test.
Are these changes tested?
Doc test
Are there any user-facing changes?