-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Add ColumnarValue::values_to_arrays, deprecate columnar_values_to_array
#9114
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
Conversation
| let args = columnar_values_to_array(args)?; | ||
| // Expand the arguments to arrays (this is simple, but inefficient for | ||
| // single constant values). | ||
| let args = ColumnarValue::values_to_arrays(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.
This is the basic change -- make the logic a function of ColumnarValue
| /// # Errors | ||
| /// | ||
| /// If there are multiple array arguments that have different lengths | ||
| pub fn values_to_arrays(args: &[ColumnarValue]) -> Result<Vec<ArrayRef>> { |
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 is a different algorithm than columnar_values_to_array as it also handles mixed ScalarValue and ArrayRefs
| use super::*; | ||
|
|
||
| #[test] | ||
| fn values_to_arrays() { |
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.
new tests
|
In the make_date code I was attempting to not actually expand the scalar into a full array but rather use in place. It was one of the reasons why I was asking about a SingleValueArray as with something like that we could have the best of both - easy processing and no data duplication. I feel though that would likely be a lot more work than it seems it would be otherwise |
viirya
left a comment
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 @alamb. Looks good to me.
Co-authored-by: Liang-Chi Hsieh <viirya@gmail.com>
|
Thanks again for the review @viirya |
Which issue does this PR close?
Part of #8045
Rationale for this change
While working on implementing
ArrayToStringin #9113 I found that many of the array functions support arbitrary combinations of arguments that areColumnarValuetoArrayby converting all the arguments to arrays and then calling a function that works on arrays.I think this is a common desire when implementing functions, but it is not always clear how to do this.
For example I think @Omega359 had to implement something similar in
to_datein #9040@viirya added a helper in #8962 which improves the situation, but I think this function may be hard to find (it is in
datafusion_physical_expr) and it doesn't handle the case where the arguments are a mix ofColumnarValue::ScalarandColumnarValue::ArrayWhat changes are included in this PR?
ColumnarValue::values_to_arrayscolumnar_values_to_arrayAre these changes tested?
Yes, new tests
Are there any user-facing changes?
New function, better docs and tests