Skip to content

Commit a1cb4fe

Browse files
timsaucerclaude
andcommitted
docs(functions): use F alias in get_field doctest
The doctest namespace already imports `datafusion.functions as F`, making `F.named_struct` / `F.get_field` shorter than the `dfn.functions.*` form. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent eb4bc9f commit a1cb4fe

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

python/datafusion/functions.py

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2749,12 +2749,10 @@ def get_field(expr: Expr, *names: Expr | str) -> Expr:
27492749
>>> df = ctx.from_pydict({"a": [1], "b": [2]})
27502750
>>> df = df.with_column(
27512751
... "s",
2752-
... dfn.functions.named_struct(
2753-
... [("x", dfn.col("a")), ("y", dfn.col("b"))]
2754-
... ),
2752+
... F.named_struct([("x", dfn.col("a")), ("y", dfn.col("b"))]),
27552753
... )
27562754
>>> result = df.select(
2757-
... dfn.functions.get_field(dfn.col("s"), "x").alias("x_val")
2755+
... F.get_field(dfn.col("s"), "x").alias("x_val")
27582756
... )
27592757
>>> result.collect_column("x_val")[0].as_py()
27602758
1
@@ -2771,12 +2769,10 @@ def get_field(expr: Expr, *names: Expr | str) -> Expr:
27712769
27722770
>>> df = df.with_column(
27732771
... "outer",
2774-
... dfn.functions.named_struct([("inner", dfn.col("s"))]),
2772+
... F.named_struct([("inner", dfn.col("s"))]),
27752773
... )
27762774
>>> result = df.select(
2777-
... dfn.functions.get_field(
2778-
... dfn.col("outer"), "inner", "x"
2779-
... ).alias("x_val")
2775+
... F.get_field(dfn.col("outer"), "inner", "x").alias("x_val")
27802776
... )
27812777
>>> result.collect_column("x_val")[0].as_py()
27822778
1

0 commit comments

Comments
 (0)