Allow the zip
compute function to operator on Scalar
values via Datum
#5086
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Closes #5011.
Rationale for this change
The arrow compute kernel function
zip
can now work on scalars, allowing a scalar value to be "zipped" with another array, repeating the scalar where needed to fill in the selected spots:If a
Scalar
value is provided, then it will be copied to fill every spot specified in themask
. Previously, callers would be required to implement this logic internally to support this.Since
&dyn Array
already implementsDatum
, existing calls will still continue to work exactly as they did before, but it is now also possible to pass in a scalar value.In addition,
&dyn Datum
now implementsDatum
. This means thatzip
can be called with the same signature as e.g.add
, which explicitly ask for&dyn Datum
; otherwise, it would not be possible to callzip
with the same kind of signature asadd
.(I think in a future PR, it would be a good idea to change
add
,sub
, and all of the other computing kernels to takeimpl Datum
parameters instead of&dyn Datum
parameters for maximum flexibility and efficiency)What changes are included in this PR?
zip
's signature changes from&dyn Array
toimpl Datum
&dyn Datum
now implementsDatum
Are there any user-facing changes?
zip
now supportsScalar
/Datum
arguments&dyn Datum
now implementsDatum