Skip to content

Commit 097373d

Browse files
committed
feat: add empty function as alias of array_empty
1 parent e015482 commit 097373d

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

docs/source/user-guide/common-operations/expressions.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ approaches.
8282
Indexing an element of an array via ``[]`` starts at index 0 whereas
8383
:py:func:`~datafusion.functions.array_element` starts at index 1.
8484

85-
To check if an array is empty, you can use the function :py:func:`datafusion.functions.array_empty`.
85+
To check if an array is empty, you can use the function :py:func:`datafusion.functions.array_empty` or `datafusion.functions.empty`.
8686
This function returns a boolean indicating whether the array is empty.
8787

8888
.. ipython:: python

python/datafusion/functions.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
"decode",
126126
"degrees",
127127
"digest",
128+
"empty",
128129
"encode",
129130
"ends_with",
130131
"exp",
@@ -1522,6 +1523,13 @@ def cardinality(array: Expr) -> Expr:
15221523
return Expr(f.cardinality(array.expr))
15231524

15241525

1526+
def empty(array: Expr) -> Expr:
1527+
"""
1528+
This is an alias for :py:func:`array_empty`.
1529+
"""
1530+
return array_empty(array)
1531+
1532+
15251533
# aggregate functions
15261534
def approx_distinct(
15271535
expression: Expr,

python/tests/test_functions.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,10 @@ def py_flatten(arr):
313313
lambda col: f.array_empty(col),
314314
lambda data: [len(r) == 0 for r in data],
315315
],
316+
[
317+
lambda col: f.empty(col),
318+
lambda data: [len(r) == 0 for r in data],
319+
],
316320
[
317321
lambda col: f.array_extract(col, literal(1)),
318322
lambda data: [r[0] for r in data],

0 commit comments

Comments
 (0)