8000 fix: add utf8_literal function to create UTF8 literal expressions in … · chenkovsky/datafusion-python@11ed674 · GitHub
[go: up one dir, main page]

Skip to content

Commit 11ed674

Browse files
committed
fix: add utf8_literal function to create UTF8 literal expressions in tests
1 parent 8e96e8e commit 11ed674

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

python/tests/test_functions.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
from datafusion import SessionContext, column
2525
from datafusion import functions as f
26-
from datafusion import literal
26+
from datafusion import literal, Expr
2727

2828
np.seterr(invalid="ignore")
2929

@@ -905,10 +905,15 @@ def test_temporal_functions(df):
905905
)
906906

907907

908+
def utf8_literal(value: str) -> Expr:
909+
"""Creates a new expression representing a UTF8 literal value."""
910+
return literal(pa.scalar(value, type=pa.string()))
911+
912+
908913
def test_arrow_cast(df):
909914
df = df.select(
910-
f.arrow_cast(column("a"), literal("Float64")).alias("a_as_float"),
911-
f.arrow_cast(column("a"), literal("Int32")).alias("a_as_int"),
915+
f.arrow_cast(column("a"), utf8_literal("Float64")).alias("a_as_float"),
916+
f.arrow_cast(column("a"), utf8_literal("Int32")).alias("a_as_int"),
912917
)
913918
result = df.collect()
914919
assert len(result) == 1

0 commit comments

Comments
 (0)
0