Skip to content

Commit db91638

Browse files
timsaucerclaude
andcommitted
Add arrays_overlap and list_overlap as aliases for array_has_any
These aliases match the upstream DataFusion SQL-level aliases, completing the set of missing array functions from issue #1452. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent ef48dd9 commit db91638

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

python/datafusion/functions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
"array_sort",
9696
"array_to_string",
9797
"array_union",
98+
"arrays_overlap",
9899
"arrays_zip",
99100
"arrow_cast",
100101
"arrow_typeof",
@@ -194,6 +195,7 @@
194195
"list_max",
195196
"list_min",
196197
"list_ndims",
198+
"list_overlap",
197199
"list_pop_back",
198200
"list_pop_front",
199201
"list_position",
@@ -2885,6 +2887,24 @@ def list_has_any(first_array: Expr, second_array: Expr) -> Expr:
28852887
return array_has_any(first_array, second_array)
28862888

28872889

2890+
def arrays_overlap(first_array: Expr, second_array: Expr) -> Expr:
2891+
"""Returns true if any element appears in both arrays.
2892+
2893+
See Also:
2894+
This is an alias for :py:func:`array_has_any`.
2895+
"""
2896+
return array_has_any(first_array, second_array)
2897+
2898+
2899+
def list_overlap(first_array: Expr, second_array: Expr) -> Expr:
2900+
"""Returns true if any element appears in both arrays.
2901+
2902+
See Also:
2903+
This is an alias for :py:func:`array_has_any`.
2904+
"""
2905+
return array_has_any(first_array, second_array)
2906+
2907+
28882908
def list_contains(array: Expr, element: Expr) -> Expr:
28892909
"""Returns true if the element appears in the array, otherwise false.
28902910

python/tests/test_functions.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,18 @@ def py_flatten(arr):
394394
),
395395
lambda data: [np.any([v in r for v in [1.0, 3.0, 5.0]]) for r in data],
396396
),
397+
(
398+
lambda col: f.arrays_overlap(
399+
col, f.make_array(*[literal(v) for v in [1.0, 3.0, 5.0]])
400+
),
401+
lambda data: [np.any([v in r for v in [1.0, 3.0, 5.0]]) for r in data],
402+
),
403+
(
404+
lambda col: f.list_overlap(
405+
col, f.make_array(*[literal(v) for v in [1.0, 3.0, 5.0]])
406+
),
407+
lambda data: [np.any([v in r for v in [1.0, 3.0, 5.0]]) for r in data],
408+
),
397409
(
398410
lambda col: f.array_position(col, literal(1.0)),
399411
lambda data: [py_indexof(r, 1.0) for r in data],

0 commit comments

Comments
 (0)