feat(functions-nested): add array_filter higher-order function#21895
Open
ologlogn wants to merge 3 commits intoapache:mainfrom
Open
feat(functions-nested): add array_filter higher-order function#21895ologlogn wants to merge 3 commits intoapache:mainfrom
ologlogn wants to merge 3 commits intoapache:mainfrom
Conversation
6ff8773 to
07e4548
Compare
Author
|
Hi @gabotechs, could you please trigger CI? Thanks! |
Implements array_filter(array, x -> condition) as a HigherOrderUDF, with alias list_filter. Evaluates a boolean lambda per element and reconstructs the list with recomputed offsets.
07e4548 to
44715ac
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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?
Partially addresses #14509 (Add Native Support for List Functions) — implements
list_filter/array_filter.Rationale for this change
array_transformwas recently added as the firstHigherOrderUDF(#21679).array_filteris the natural companion: filter elements of an array using a boolean lambda predicate, analogous to Spark'sfilterand DuckDB'slist_filter.What changes are included in this PR?
HigherOrderUDFArrayFilterindatafusion/functions-nested/src/array_filter.rsarray_filter(array, x -> condition)with aliaslist_filtertrueare keptfalse(element dropped), matching Spark semanticsListandLargeList, sliced arrays, and null sublists correctlyarrow::compute::filtermacros_lambda.rs(value_lambda_pair,coerce_single_list_arg) to avoid duplication witharray_transformtest_utils.rs(create_i32_list,eval_hof_on_i32_list,v())all_default_higher_order_functions()andexpr_fnAre these changes tested?
Yes, unit tests cover:
x -> x > 2)Are there any user-facing changes?
Yes —
array_filter(array, lambda)and its aliaslist_filter(array, lambda)are now available as SQL functions.