File tree Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Expand file tree Collapse file tree 3 files changed +15
-8
lines changed Original file line number Diff line number Diff line change @@ -107,9 +107,16 @@ def literal(value):
107
107
return Expr .literal (value )
108
108
109
109
110
- def utf8_literal (value ):
111
- """Create a UTF8 literal expression."""
112
- return Expr .utf8_literal (value )
110
+ def string_literal (value ):
111
+ """Create a UTF8 literal expression.
112
+ It differs from `literal` creates a UTF8view literal.
113
+ """
114
+ return Expr .string_literal (value )
115
+
116
+
117
+ def str_lit (value ):
118
+ """Alias for `string_literal`"""
119
+ return string_literal (value )
113
120
114
121
115
122
def lit (value ):
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ def literal(value: Any) -> Expr:
381
381
return Expr (expr_internal .Expr .literal (value ))
382
382
383
383
@staticmethod
384
- def utf8_literal (value : str ) -> Expr :
384
+ def string_literal (value : str ) -> Expr :
385
385
"""Creates a new expression representing a UTF8 literal value.
386
386
387
387
It is different from `literal` because it is pa.string() instead of
Original file line number Diff line number Diff line change 23
23
24
24
from datafusion import SessionContext , column
25
25
from datafusion import functions as f
26
- from datafusion import literal , utf8_literal
26
+ from datafusion import literal , string_literal
27
27
28
28
np .seterr (invalid = "ignore" )
29
29
@@ -909,11 +909,11 @@ def test_temporal_functions(df):
909
909
910
910
def test_arrow_cast (df ):
911
911
df = df .select (
912
- # we use `utf8_literal ` to return utf8 instead of `literal` which returns
912
+ # we use `string_literal ` to return utf8 instead of `literal` which returns
913
913
# utf8view because datafusion.arrow_cast expects a utf8 instead of utf8view
914
914
# https://github.com/apache/datafusion/blob/86740bfd3d9831d6b7c1d0e1bf4a21d91598a0ac/datafusion/functions/src/core/arrow_cast.rs#L179
915
- f .arrow_cast (column ("b" ), utf8_literal ("Float64" )).alias ("b_as_float" ),
916
- f .arrow_cast (column ("b" ), utf8_literal ("Int32" )).alias ("b_as_int" ),
915
+ f .arrow_cast (column ("b" ), string_literal ("Float64" )).alias ("b_as_float" ),
916
+ f .arrow_cast (column ("b" ), string_literal ("Int32" )).alias ("b_as_int" ),
917
917
)
918
918
result = df .collect ()
919
919
assert len (result ) == 1
You can’t perform that action at this time.
0 commit comments