Skip to content

Commit d12f721

Browse files
timsaucerclaude
andcommitted
Fix arrow_cast with pyarrow DataType by delegating to Expr.cast
Use the existing Rust-side PyArrowType<DataType> conversion via Expr.cast() instead of str() which produces pyarrow type names that DataFusion does not recognize. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent f760e70 commit d12f721

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

python/datafusion/functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2658,7 +2658,7 @@ def arrow_cast(expr: Expr, data_type: Expr | str | pa.DataType) -> Expr:
26582658
1.0
26592659
"""
26602660
if isinstance(data_type, pa.DataType):
2661-
data_type = str(data_type)
2661+
return expr.cast(data_type)
26622662
if isinstance(data_type, str):
26632663
data_type = Expr.string_literal(data_type)
26642664
return Expr(f.arrow_cast(expr.expr, data_type.expr))
@@ -2789,7 +2789,7 @@ def version() -> Expr:
27892789
27902790
Examples:
27912791
>>> ctx = dfn.SessionContext()
2792-
>>> df = ctx.from_pydict({"a": [1]})
2792+
>>> df = ctx.empty_table()
27932793
>>> result = df.select(dfn.functions.version().alias("v"))
27942794
>>> "Apache DataFusion" in result.collect_column("v")[0].as_py()
27952795
True

0 commit comments

Comments
 (0)