Skip to content

Commit f27707e

Browse files
committed
docs: document null-handling function arguments
1 parent 13b2c47 commit f27707e

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
@@ -908,6 +908,9 @@ def chr(arg: Expr) -> Expr:
908908
def coalesce(*args: Expr) -> Expr:
909909
"""Returns the value of the first expr in ``args`` which is not NULL.
910910
911+
Args:
912+
*args: Expressions to evaluate in order.
913+
911914
Examples:
912915
>>> ctx = dfn.SessionContext()
913916
>>> df = ctx.from_pydict({"a": [None, 1], "b": [2, 3]})
@@ -1089,6 +1092,10 @@ def greatest(*args: Expr) -> Expr:
10891092
def ifnull(x: Expr, y: Expr) -> Expr:
10901093
"""Returns ``x`` if ``x`` is not NULL. Otherwise returns ``y``.
10911094
1095+
Args:
1096+
x: Expression to return when it is not NULL.
1097+
y: Fallback expression to return when ``x`` is NULL.
1098+
10921099
See Also:
10931100
This is an alias for :py:func:`nvl`.
10941101
"""
@@ -1323,6 +1330,10 @@ def md5(arg: Expr) -> Expr:
13231330
def nanvl(x: Expr, y: Expr) -> Expr:
13241331
"""Returns ``x`` if ``x`` is not ``NaN``. Otherwise returns ``y``.
13251332
1333+
Args:
1334+
x: Expression to return when it is not NaN.
1335+
y: Fallback expression to return when ``x`` is NaN.
1336+
13261337
Examples:
13271338
>>> ctx = dfn.SessionContext()
13281339
>>> df = ctx.from_pydict({"a": [np.nan, 1.0], "b": [0.0, 0.0]})
@@ -1339,6 +1350,10 @@ def nanvl(x: Expr, y: Expr) -> Expr:
13391350
def nvl(x: Expr, y: Expr) -> Expr:
13401351
"""Returns ``x`` if ``x`` is not ``NULL``. Otherwise returns ``y``.
13411352
1353+
Args:
1354+
x: Expression to return when it is not NULL.
1355+
y: Fallback expression to return when ``x`` is NULL.
1356+
13421357
Examples:
13431358
>>> ctx = dfn.SessionContext()
13441359
>>> df = ctx.from_pydict({"a": [None, 1], "b": [0, 0]})
@@ -1356,6 +1371,11 @@ def nvl(x: Expr, y: Expr) -> Expr:
13561371
def nvl2(x: Expr, y: Expr, z: Expr) -> Expr:
13571372
"""Returns ``y`` if ``x`` is not NULL. Otherwise returns ``z``.
13581373
1374+
Args:
1375+
x: Expression to check for NULL.
1376+
y: Expression to return when ``x`` is not NULL.
1377+
z: Expression to return when ``x`` is NULL.
1378+
13591379
Examples:
13601380
>>> ctx = dfn.SessionContext()
13611381
>>> df = ctx.from_pydict({"a": [None, 1], "b": [10, 20], "c": [30, 40]})

0 commit comments

Comments
 (0)