Skip to content

Commit 74315c2

Browse files
timsaucerclaude
andcommitted
docs: correct how to set null treatment on a window and list array_first
The Null Treatment section said null treatment needs the builder, but its own example passes it in the Window, and over() now keeps one set on the aggregate. The higher-order functions list in expressions.md also missed array_first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent 5d79982 commit 74315c2

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

‎docs/source/user-guide/common-operations/expressions.md‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,9 @@ In this example, the `repeated_array` column will contain `[[1, 2, 3], [1, 2, 3]
157157
Some array functions take a *lambda function*: a small function that runs once
158158
per element. {py:func}`~datafusion.functions.array_transform` maps a lambda over
159159
every element, {py:func}`~datafusion.functions.array_filter` keeps the elements
160-
for which a predicate lambda is true, and
160+
for which a predicate lambda is true,
161+
{py:func}`~datafusion.functions.array_first` returns the first element that
162+
satisfies a predicate lambda, and
161163
{py:func}`~datafusion.functions.array_any_match` returns whether any element
162164
satisfies a predicate lambda. (Functions that take another function as an
163165
argument are sometimes called *higher-order* functions.)
@@ -173,6 +175,7 @@ ctx = SessionContext()
173175
df = ctx.from_pydict({"a": [[1, 2, 3], [4, 5]]})
174176
df.select(f.array_transform(col("a"), lambda v: v * 2).alias("doubled"))
175177
df.select(f.array_filter(col("a"), lambda v: v > 2).alias("big_only"))
178+
df.select(f.array_first(col("a"), lambda v: v > 2).alias("first_big"))
176179
df.select(f.array_any_match(col("a"), lambda v: v > 3).alias("has_big"))
177180
```
178181

‎docs/source/user-guide/common-operations/windows.md‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,8 @@ f.sum(col("v")).over(Window(order_by=col("v"), window_frame=whole))
181181
### Null Treatment
182182

183183
When using aggregate functions as window functions, it is often useful to specify how null values
184-
should be treated. In order to do this you need to use the builder function. In future releases
185-
we expect this to be simplified in the interface.
184+
should be treated. Pass `null_treatment` in the `Window`, or set it on the aggregate itself, which
185+
`over()` keeps (see {ref}`aggregate_over_options`).
186186

187187
One common usage for handling nulls is the case where you want to find the last value up to the
188188
current row. In the following example we demonstrate how setting the null treatment to ignore

0 commit comments

Comments
 (0)