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):
107107 return Expr .literal (value )
108108
109109
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 )
113120
114121
115122def lit (value ):
Original file line number Diff line number Diff line change @@ -381,7 +381,7 @@ def literal(value: Any) -> Expr:
381381 return Expr (expr_internal .Expr .literal (value ))
382382
383383 @staticmethod
384- def utf8_literal (value : str ) -> Expr :
384+ def string_literal (value : str ) -> Expr :
385385 """Creates a new expression representing a UTF8 literal value.
386386
387387 It is different from `literal` because it is pa.string() instead of
Original file line number Diff line number Diff line change 2323
2424from datafusion import SessionContext , column
2525from datafusion import functions as f
26- from datafusion import literal , utf8_literal
26+ from datafusion import literal , string_literal
2727
2828np .seterr (invalid = "ignore" )
2929
@@ -909,11 +909,11 @@ def test_temporal_functions(df):
909909
910910def test_arrow_cast (df ):
911911 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
913913 # utf8view because datafusion.arrow_cast expects a utf8 instead of utf8view
914914 # 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" ),
917917 )
918918 result = df .collect ()
919919 assert len (result ) == 1
You can’t perform that action at this time.
0 commit comments