Skip to content

Commit 66bfe36

Browse files
authored
Bugfix: Calling count with None arguments (#768)
* Small bugfix. When arguments are None, we should use count_star * When no arguments are given to count, set argument to lit(1) so that it is similar to count_star but still enables you to select distinct=True.
1 parent f580155 commit 66bfe36

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

python/datafusion/functions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1295,6 +1295,8 @@ def corr(value1: Expr, value2: Expr, distinct: bool = False) -> Expr:
12951295

12961296
def count(args: Expr | list[Expr] | None = None, distinct: bool = False) -> Expr:
12971297
"""Returns the number of rows that match the given arguments."""
1298+
if args is None:
1299+
return count(Expr.literal(1), distinct=distinct)
12981300
if isinstance(args, list):
12991301
args = [arg.expr for arg in args]
13001302
elif isinstance(args, Expr):

0 commit comments

Comments
 (0)