-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Support array concatenation for arrays with different dimensions #6872
Conversation
Signed-off-by: jayzhan211 <[email protected]>
@izveigor do you have time to review this PR, perhaps? |
@@ -365,6 +365,31 @@ select array_concat(make_array(), make_array(2, 3)); | |||
---- | |||
[2, 3] | |||
|
|||
# array_concat with different dimensions |
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.
In my opinion, it would be better to write # array_concat with different dimensions #1 (2D + 1D)
in all test cases (where 1
is the test case number).
select array_concat(make_array(10, 20), make_array([30, 40]), make_array([[50, 60]])) | ||
---- | ||
[[[10, 20]], [[30, 40]], [[50, 60]]] | ||
|
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.
We also have test cases with the concatenation operator.
Could you please write some test cases with it?
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 PR fails on the concatenation operator. I will request another PR on this.
|
||
fn align_array_dimensions(args: Vec<ArrayRef>) -> Result<Vec<ArrayRef>> { | ||
// Compute the number of dimensions for each array | ||
let args_ndim: Result<Vec<u8>> = args |
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.
let args_ndim = args.iter().map(|arr| compute_array_ndims(0, arr.clone).max()?;
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.
Thank you, @jayzhan211!
I left a few minor nitpicks. But I think that the code does not contain serious errors.
Signed-off-by: jayzhan211 <[email protected]>
ab4f6a8
to
88bca14
Compare
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.
Thank you @jayzhan211 and @izveigor
Which issue does this PR close?
Ref #6849
Rationale for this change
What changes are included in this PR?
Calculate dims for each array in concat(), find the max one, and wrap each array to the same dims.
Note that this change does not restrict that each array dimension should be diff by 1 as mentioned in the issue, but I think it is fine not to restrict that, If we need to ensure that, we just need additional error handling.
Are these changes tested?
Are there any user-facing changes?