Skip to content

Commit 23f9179

Browse files
authored
docs: document null-handling function arguments (#1527)
Co-authored-by: BharatDeva <278575558+BharatDeva@users.noreply.github.com>
1 parent 56b1cea commit 23f9179

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

python/datafusion/functions.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,9 @@ def chr(arg: Expr) -> Expr:
910910
def coalesce(*args: Expr) -> Expr:
911911
"""Returns the value of the first expr in ``args`` which is not NULL.
912912
913+
Args:
914+
*args: Expressions to evaluate in order.
915+
913916
Examples:
914917
>>> ctx = dfn.SessionContext()
915918
>>> df = ctx.from_pydict({"a": [None, 1], "b": [2, 3]})
@@ -1091,6 +1094,10 @@ def greatest(*args: Expr) -> Expr:
10911094
def ifnull(x: Expr, y: Expr) -> Expr:
10921095
"""Returns ``x`` if ``x`` is not NULL. Otherwise returns ``y``.
10931096
1097+
Args:
1098+
x: Expression to return when it is not NULL.
1099+
y: Fallback expression to return when ``x`` is NULL.
1100+
10941101
See Also:
10951102
This is an alias for :py:func:`nvl`.
10961103
"""
@@ -1325,6 +1332,10 @@ def md5(arg: Expr) -> Expr:
13251332
def nanvl(x: Expr, y: Expr) -> Expr:
13261333
"""Returns ``x`` if ``x`` is not ``NaN``. Otherwise returns ``y``.
13271334
1335+
Args:
1336+
x: Expression to return when it is not NaN.
1337+
y: Fallback expression to return when ``x`` is NaN.
1338+
13281339
Examples:
13291340
>>> ctx = dfn.SessionContext()
13301341
>>> df = ctx.from_pydict({"a": [np.nan, 1.0], "b": [0.0, 0.0]})
@@ -1341,6 +1352,10 @@ def nanvl(x: Expr, y: Expr) -> Expr:
13411352
def nvl(x: Expr, y: Expr) -> Expr:
13421353
"""Returns ``x`` if ``x`` is not ``NULL``. Otherwise returns ``y``.
13431354
1355+
Args:
1356+
x: Expression to return when it is not NULL.
1357+
y: Fallback expression to return when ``x`` is NULL.
1358+
13441359
Examples:
13451360
>>> ctx = dfn.SessionContext()
13461361
>>> df = ctx.from_pydict({"a": [None, 1], "b": [0, 0]})
@@ -1358,6 +1373,11 @@ def nvl(x: Expr, y: Expr) -> Expr:
13581373
def nvl2(x: Expr, y: Expr, z: Expr) -> Expr:
13591374
"""Returns ``y`` if ``x`` is not NULL. Otherwise returns ``z``.
13601375
1376+
Args:
1377+
x: Expression to check for NULL.
1378+
y: Expression to return when ``x`` is not NULL.
1379+
z: Expression to return when ``x`` is NULL.
1380+
13611381
Examples:
13621382
>>> ctx = dfn.SessionContext()
13631383
>>> df = ctx.from_pydict({"a": [None, 1], "b": [10, 20], "c": [30, 40]})

0 commit comments

Comments
 (0)