Commit e18b1cf
add any_match higher-order function (apache#21903)
## Which issue does this PR close?
<!--
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. For example
`Closes apache#123` indicates that this PR will close issue apache#123.
-->
- Closes #.
## Rationale for this change
`array_any_match` is a commonly supported higher-order function in
systems like Spark (`exists`), Trino (`any_match`) among other engines.
It seems like a natural first addition alongside `array_transform` and
worth upstreaming I think.
## What changes are included in this PR?
Adds `array_any_match(array, predicate)` as a new higher-order function
(with aliases `any_match` and `list_any_match`). It returns:
`true` if any element satisfies the predicate
`false` if no element does (including empty arrays)
`null` if the predicate returns null for some elements and false for all
others
## Are these changes tested?
Yes I added unit tests and sqllogic tests
## Are there any user-facing changes?
Yes -- new SQL functions array_any_match, any_match, and list_any_match
are available.
---------
Co-authored-by: Dmitrii Blaginin <dmitrii@blaginin.me>1 parent 702f479 commit e18b1cf
5 files changed
Lines changed: 632 additions & 4 deletions
File tree
- datafusion
- functions-nested/src
- sqllogictest/test_files/array
- docs/source/user-guide/sql
0 commit comments