Skip to content

Commit 4a8fadc

Browse files
timsaucerclaude
andcommitted
docs(example): note null→0 coercion in above-threshold UDF
The `(v.as_py() or 0) > threshold` line was reading as canonical Python UDF style. Add a one-line comment flagging that nulls silently coerce to 0 — fine for the demo dataset (no nulls), but real code should pick the semantics explicitly. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 2f241be commit 4a8fadc

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

examples/multiprocessing_pickle_expr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,9 @@ def make_above_threshold_udf(threshold: int) -> ScalarUDF:
6464
"""
6565

6666
def above(arr: pa.Array) -> pa.Array:
67+
# `v.as_py() or 0` coerces nulls to 0 — the demo dataset has no
68+
# nulls, but real-world code should decide explicitly how nulls
69+
# compare against the threshold.
6770
return pa.array([1 if (v.as_py() or 0) > threshold else 0 for v in arr])
6871

6972
return udf(

0 commit comments

Comments
 (0)