diff --git a/python/datafusion/expr.py b/python/datafusion/expr.py index 5c14362a..df19dfc6 100644 --- a/python/datafusion/expr.py +++ b/python/datafusion/expr.py @@ -374,6 +374,8 @@ def literal(value: Any) -> Expr: ``value`` must be a valid PyArrow scalar value or easily castable to one. """ + if isinstance(value, str): + value = pa.scalar(value, type=pa.string_view()) if not isinstance(value, pa.Scalar): value = pa.scalar(value) return Expr(expr_internal.Expr.literal(value)) @@ -419,7 +421,7 @@ def fill_null(self, value: Any | Expr | None = None) -> Expr: _to_pyarrow_types = { float: pa.float64(), int: pa.int64(), - str: pa.string(), + str: pa.string_view(), bool: pa.bool_(), }