Skip to content

Commit 61115b3

Browse files
committed
fix: update arrow_cast function to accept Expr type for data_type parameter
1 parent e623ae3 commit 61115b3

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
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: str) -> Expr:
1103+
def arrow_cast(expr: Expr, data_type: Expr) -> Expr:
11041104
"""Casts an expression to a specified data type."""
1105-
return Expr(f.arrow_cast(expr.expr, data_type))
1105+
return Expr(f.arrow_cast(expr.expr, data_type.expr))
11061106

11071107

11081108
def random() -> Expr:

src/functions.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ expr_fn_vec!(r#struct); // Use raw identifier since struct is a keyword
563563
expr_fn_vec!(named_struct);
564564
expr_fn!(from_unixtime, unixtime);
565565
expr_fn!(arrow_typeof, arg_1);
566-
expr_fn!(arrow_cast, datatype);
566+
expr_fn!(arrow_cast, column datatype);
567567
expr_fn!(random);
568568

569569
// Array Functions
@@ -856,6 +856,7 @@ pub(crate) fn init_module(m: &Bound<'_, PyModule>) -> PyResult<()> {
856856
m.add_wrapped(wrap_pyfunction!(range))?;
857857
m.add_wrapped(wrap_pyfunction!(array_agg))?;
858858
m.add_wrapped(wrap_pyfunction!(arrow_typeof))?;
859+
m.add_wrapped(wrap_pyfunction!(arrow_cast))?;
859860
m.add_wrapped(wrap_pyfunction!(ascii))?;
860861
m.add_wrapped(wrap_pyfunction!(asin))?;
861862
m.add_wrapped(wrap_pyfunction!(asinh))?;

0 commit comments

Comments
 (0)