support length() on Run-end encoding arrays - #9838
Conversation
Jefffrey
left a comment
There was a problem hiding this comment.
I wonder if we should introduce something like AnyDictionaryArray but for run arrays, which could simplify much of the code required here 🤔
(As a followup)
|
yea I think that would be neat. Im going to work on #7693 if theres a similar need ill make a PR that creates an Any_REE_Array and then update this PR & that PR to use it instead of duplicating code |
|
@Jefffrey do I need to click on something else to merge the PR? |
no, we'll handle merging it. Thank you |
alamb
left a comment
There was a problem hiding this comment.
Thanks @Rich-T-kid and @Jefffrey
| macro_rules! ree_length { | ||
| ($array:expr, $run_type:ty, $k:expr, $v:expr) => {{ | ||
| let ree = $array.as_run_opt::<$run_type>().unwrap(); | ||
| let inner_value_lengths = length(ree.values().as_ref())?; |
There was a problem hiding this comment.
this pattern of 'replaces the values of the REE array' is probably common enough to warrant its own function on RunArray eventually. Maybe some thing like
let out_ree = ree.with_new_values(inner_value_lengths)And then internally it can update the data type and that the number of inner values is correct 🤔
There was a problem hiding this comment.
yea I agree, similar to jefffrey's comments if I come across it while working on another PR ill make a PR addressing it.
There was a problem hiding this comment.
Thanks -- filed a tracking ticket
# Which issue does this PR close? works towards closing apache#3520, adds run-end encoding support for legnth operations when the values array is valid. <!-- We generally require a GitHub issue to be filed for all bug fixes and enhancements and this helps us generate change logs for our releases. You can link an issue to this PR using the GitHub syntax. --> # Rationale for this change REE is unsupported to length <!-- Why are you proposing this change? If this is already explained clearly in the issue then this section is not needed. Explaining clearly why changes are proposed helps reviewers understand your changes and offer better suggestions for fixes. --> # What changes are included in this PR? Introduces a macro to handle each REE run-end index type, eliminating duplicated logic across match arms. The macro uses **new_unchecked** instead of **try_new** to skip redundant validation, since the input is already a valid REE array and length has its own error handling, the invariants are guaranteed to hold before the unchecked call. <!-- There is no need to duplicate the description in the issue here but it is sometimes worth providing a summary of the individual changes in this PR. --> # Are these changes tested? Yes. <!-- We typically require tests for all PRs in order to: 1. Prevent the code from being accidentally broken by subsequent changes 2. Serve as another way to document the expected behavior of the code If tests are not included in your PR, please explain why (for example, are they covered by existing tests)? --> # Are there any user-facing changes? Yes, this allows callers to invoke **length()** directly on REE-encoded columns without materializing or casting to a primitive array first. <!-- If there are user-facing changes then we may require documentation to be updated before approving the PR. If there are any breaking changes to public APIs, please call them out. -->
Which issue does this PR close?
works towards closing #3520, adds run-end encoding support for legnth operations when the values array is valid.
Rationale for this change
REE is unsupported to length
What changes are included in this PR?
Introduces a macro to handle each REE run-end index type, eliminating duplicated logic across match arms. The macro uses new_unchecked instead of try_new to skip redundant validation, since the input is already a valid REE array and length has its own error handling, the invariants are guaranteed to hold before the unchecked call.
Are these changes tested?
Yes.
Are there any user-facing changes?
Yes, this allows callers to invoke length() directly on REE-encoded columns without materializing or casting to a primitive array first.