Skip to content

Commit 056f712

Browse files
timsaucerclaude
andcommitted
Clarify when to use arrow_cast vs Expr.cast in docstring
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent d12f721 commit 056f712

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

python/datafusion/functions.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2637,7 +2637,13 @@ def arrow_typeof(arg: Expr) -> Expr:
26372637
def arrow_cast(expr: Expr, data_type: Expr | str | pa.DataType) -> Expr:
26382638
"""Casts an expression to a specified data type.
26392639
2640-
The ``data_type`` can be a string, a ``pyarrow.DataType``, or an ``Expr``.
2640+
The ``data_type`` can be a string, a ``pyarrow.DataType``, or an
2641+
``Expr``. For simple types, :py:meth:`Expr.cast()
2642+
<datafusion.expr.Expr.cast>` is more concise
2643+
(e.g., ``col("a").cast(pa.float64())``). Use ``arrow_cast`` when
2644+
you want to specify the target type as a string using DataFusion's
2645+
type syntax, which can be more readable for complex types like
2646+
``"Timestamp(Nanosecond, None)"``.
26412647
26422648
Examples:
26432649
>>> ctx = dfn.SessionContext()

0 commit comments

Comments
 (0)