Skip to content

Commit 3a5e210

Browse files
committed
Revert "fix: update arrow_cast function to accept string type for data_type parameter"
This reverts commit eba0d32.
1 parent eba0d32 commit 3a5e210

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

python/datafusion/functions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
"""User functions for operating on :py:class:`~datafusion.expr.Expr`."""
1818

1919
from __future__ import annotations
20+
2021
from datafusion._internal import functions as f
2122
from datafusion.expr import (
2223
CaseBuilder,
@@ -1099,9 +1100,9 @@ def arrow_typeof(arg: Expr) -> Expr:
10991100
return Expr(f.arrow_typeof(arg.expr))
11001101

11011102

1102-
def arrow_cast(expr: Expr, data_type: str) -> Expr:
1103+
def arrow_cast(expr: Expr, data_type: Expr) -> Expr:
11031104
"""Casts an expression to a specified data type."""
1104-
return Expr(f.arrow_cast(expr.expr, literal(data_type).expr))
1105+
return Expr(f.arrow_cast(expr.expr, data_type.expr))
11051106

11061107

11071108
def random() -> Expr:

python/tests/test_functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -907,8 +907,8 @@ def test_temporal_functions(df):
907907

908908
def test_arrow_cast(df):
909909
df = df.select(
910-
f.arrow_cast(column("a"), "Float64").alias("a_as_float"),
911-
f.arrow_cast(column("a"), "Int32").alias("a_as_int"),
910+
f.arrow_cast(column("a"), literal("Float64")).alias("a_as_float"),
911+
f.arrow_cast(column("a"), literal("Int32")).alias("a_as_int"),
912912
)
913913
result = df.collect()
914914
assert len(result) == 1

0 commit comments

Comments
 (0)