Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dask_sql/physical/rex/core/call.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,7 @@ class RexCallPlugin(BaseRexPlugin):
"truncate": Operation(da.trunc),
# string operations
"||": ReduceOperation(operation=operator.add),
"concat": ReduceOperation(operation=operator.add),
"char_length": TensorScalarOperation(lambda x: x.str.len(), lambda x: len(x)),
"upper": TensorScalarOperation(lambda x: x.str.upper(), lambda x: x.upper()),
"lower": TensorScalarOperation(lambda x: x.str.lower(), lambda x: x.lower()),
Expand Down
70 changes: 36 additions & 34 deletions tests/integration/test_rex.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,25 +411,26 @@ def test_string_functions(c):
"""
SELECT
a || 'hello' || a AS a,
CHAR_LENGTH(a) AS b,
UPPER(a) AS c,
LOWER(a) AS d,
POSITION('a' IN a FROM 4) AS e,
POSITION('ZL' IN a) AS f,
TRIM('a' FROM a) AS g,
TRIM(BOTH 'a' FROM a) AS h,
TRIM(LEADING 'a' FROM a) AS i,
TRIM(TRAILING 'a' FROM a) AS j,
OVERLAY(a PLACING 'XXX' FROM -1) AS k,
OVERLAY(a PLACING 'XXX' FROM 2 FOR 4) AS l,
OVERLAY(a PLACING 'XXX' FROM 2 FOR 1) AS m,
SUBSTRING(a FROM -1) AS n,
SUBSTRING(a FROM 10) AS o,
SUBSTRING(a FROM 2) AS p,
SUBSTRING(a FROM 2 FOR 2) AS q,
INITCAP(a) AS r,
INITCAP(UPPER(a)) AS s,
INITCAP(LOWER(a)) AS t
CONCAT(a, 'hello', a) as b,
CHAR_LENGTH(a) AS c,
UPPER(a) AS d,
LOWER(a) AS e,
POSITION('a' IN a FROM 4) AS f,
POSITION('ZL' IN a) AS g,
TRIM('a' FROM a) AS h,
TRIM(BOTH 'a' FROM a) AS i,
TRIM(LEADING 'a' FROM a) AS j,
TRIM(TRAILING 'a' FROM a) AS k,
OVERLAY(a PLACING 'XXX' FROM -1) AS l,
OVERLAY(a PLACING 'XXX' FROM 2 FOR 4) AS m,
OVERLAY(a PLACING 'XXX' FROM 2 FOR 1) AS n,
SUBSTRING(a FROM -1) AS o,
SUBSTRING(a FROM 10) AS p,
SUBSTRING(a FROM 2) AS q,
SUBSTRING(a FROM 2 FOR 2) AS r,
INITCAP(a) AS s,
INITCAP(UPPER(a)) AS t,
INITCAP(LOWER(a)) AS u
FROM
string_table
"""
Expand All @@ -438,25 +439,26 @@ def test_string_functions(c):
expected_df = pd.DataFrame(
{
"a": ["a normal stringhelloa normal string"],
"b": [15],
"c": ["A NORMAL STRING"],
"d": ["a normal string"],
"e": [7],
"f": [0],
"g": [" normal string"],
"b": ["a normal stringhelloa normal string"],
"c": [15],
"d": ["A NORMAL STRING"],
"e": ["a normal string"],
"f": [7],
"g": [0],
"h": [" normal string"],
"i": [" normal string"],
"j": ["a normal string"],
"k": ["XXXormal string"],
"l": ["aXXXmal string"],
"m": ["aXXXnormal string"],
"n": ["a normal string"],
"o": ["string"],
"p": [" normal string"],
"q": [" n"],
"r": ["A Normal String"],
"j": [" normal string"],
"k": ["a normal string"],
"l": ["XXXormal string"],
"m": ["aXXXmal string"],
"n": ["aXXXnormal string"],
"o": ["a normal string"],
"p": ["string"],
"q": [" normal string"],
"r": [" n"],
"s": ["A Normal String"],
"t": ["A Normal String"],
"u": ["A Normal String"],
}
)

Expand Down