8000 fix: update arrow_cast function to accept string type for data_type p… · kosiew/datafusion-python@20cc781 · GitHub
[go: up one dir, main page]

Skip to content

Commit 20cc781

Browse files
committed
fix: update arrow_cast function to accept string type for data_type parameter
1 parent 11071e6 commit 20cc781

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

python/datafusion/functions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,9 +1100,9 @@ def arrow_typeof(arg: Expr) -> Expr:
11001100
return Expr(f.arrow_typeof(arg.expr))
11011101

11021102

1103-
def arrow_cast(expr: Expr, data_type: Expr) -> Expr:
1103+
def arrow_cast(expr: Expr, data_type: str) -> Expr:
11041104
"""Casts an expression to a specified data type."""
1105-
return Expr(f.arrow_cast(expr.expr, data_type.expr))
1105+
return Expr(f.arrow_cast(expr.expr, data_type))
11061106

11071107

11081108
def random() -> Expr:

python/tests/test_functions.py

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

908908
def test_arrow_cast(df):
909909
df = df.select(
910-
f.arrow_cast(column("a"), literal("Float64").cast(pa.string())).alias(
911-
"a_as_float"
912-
),
913-
f.arrow_cast(column("a"), literal("Int32").cast(pa.string())).alias("a_as_int"),
910+
f.arrow_cast(column("a"), "Float64").alias("a_as_float"),
911+
f.arrow_cast(column("a"), "Int32").alias("a_as_int"),
914912
)
915913
result = df.collect()
916914
assert len(result) == 1

0 commit comments

Comments
 (0)
0