Skip to content

Commit bfc79e9

Browse files
timsaucerclaude
andcommitted
docs: emphasize lambda terminology, trim skill lambda section
Lead user-facing array-lambda docs with "lambda function" instead of "higher-order function," which is less recognizable to users. Drop the alias list, serialization caveat, and DuckDB-dialect note from the skill to keep it lean; those details already live in the docstrings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 1b3d543 commit bfc79e9

2 files changed

Lines changed: 10 additions & 17 deletions

File tree

docs/source/user-guide/common-operations/expressions.rst

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -145,15 +145,16 @@ This function returns a new array with the elements repeated.
145145
146146
In this example, the `repeated_array` column will contain `[[1, 2, 3], [1, 2, 3]]`.
147147

148-
Higher-order functions and lambdas
149-
----------------------------------
148+
Lambda functions
149+
----------------
150150

151-
Some array functions are *higher-order*: they take a lambda that runs once per
152-
element. :py:func:`~datafusion.functions.array_transform` maps a lambda over
151+
Some array functions take a *lambda function*: a small function that runs once
152+
per element. :py:func:`~datafusion.functions.array_transform` maps a lambda over
153153
every element, :py:func:`~datafusion.functions.array_filter` keeps the elements
154154
for which a predicate lambda is true, and
155155
:py:func:`~datafusion.functions.array_any_match` returns whether any element
156-
satisfies a predicate lambda.
156+
satisfies a predicate lambda. (Functions that take another function as an
157+
argument are sometimes called *higher-order* functions.)
157158

158159
The simplest way to supply a lambda is a Python ``lambda``. Its parameter names
159160
become the lambda parameters, and its return value becomes the body.

skills/datafusion_python/SKILL.md

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -488,32 +488,24 @@ col("array_col")[0] # access array element (0-indexed)
488488
col("array_col")[1:3] # array slice (0-indexed)
489489
```
490490

491-
### Higher-Order Array Functions (Lambdas)
491+
### Lambda Functions
492492

493-
Some array functions take a lambda that runs once per element. Pass a Python
494-
`lambda` directly — its parameter names become the lambda parameters and its
495-
return value becomes the body:
493+
Some array functions take a lambda function that runs once per element. Pass a
494+
Python `lambda` directly — its parameter names become the lambda parameters and
495+
its return value becomes the body:
496496

497497
```python
498498
F.array_transform(col("a"), lambda v: v * 2) # map: [1,2,3] -> [2,4,6]
499499
F.array_filter(col("a"), lambda v: v > 2) # filter: [1,2,3] -> [3]
500500
F.array_any_match(col("a"), lambda v: v > 3) # predicate: any element > 3
501501
```
502502

503-
Aliases: `list_transform` for `array_transform`; `list_filter` for
504-
`array_filter`; `any_match` / `list_any_match` for `array_any_match`.
505-
506503
For explicit parameter names, build the lambda by hand:
507504

508505
```python
509506
F.array_transform(col("a"), F.lambda_(["v"], F.lambda_var("v") * lit(2)))
510507
```
511508

512-
Limitations: lambda expressions cannot be serialized (`Expr.to_bytes` / pickle
513-
raise `Lambda not implemented`). SQL lambda syntax (`x -> x * 2`) needs the
514-
DuckDB dialect (`SessionConfig().set("datafusion.sql_parser.dialect", "DuckDB")`);
515-
the Python builder above is dialect-independent.
516-
517509
## SQL-to-DataFrame Reference
518510

519511
| SQL | DataFrame API |

0 commit comments

Comments
 (0)