Skip to content

Commit

Permalink
Add tests for encode/decode utf-32
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirg-db committed May 8, 2024
1 parent a785897 commit 9e7debe
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -489,6 +489,8 @@ class StringExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
// non ascii characters are not allowed in the code, so we disable the scalastyle here.
checkEvaluation(
StringDecode(Encode(Literal("大千世界"), Literal("UTF-16LE")), Literal("UTF-16LE")), "大千世界")
checkEvaluation(
StringDecode(Encode(Literal("大千世界"), Literal("UTF-32")), Literal("UTF-32")), "大千世界")
checkEvaluation(
StringDecode(Encode(a, Literal("utf-8")), Literal("utf-8")), "大千世界", create_row("大千世界"))
checkEvaluation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ Project [decode(encode(abc, utf-8, false), utf-8) AS decode(encode(abc, utf-8),
+- OneRowRelation


-- !query
select decode(encode('大千世界', 'utf-32'), 'utf-32')
-- !query analysis
Project [decode(encode(大千世界, utf-32, false), utf-32) AS decode(encode(大千世界, utf-32), utf-32)#x]
+- OneRowRelation


-- !query
select decode(1, 1, 'Southlake')
-- !query analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,13 @@ Project [decode(encode(abc, utf-8, false), utf-8) AS decode(encode(abc, utf-8),
+- OneRowRelation


-- !query
select decode(encode('大千世界', 'utf-32'), 'utf-32')
-- !query analysis
Project [decode(encode(大千世界, utf-32, false), utf-32) AS decode(encode(大千世界, utf-32), utf-32)#x]
+- OneRowRelation


-- !query
select decode(1, 1, 'Southlake')
-- !query analysis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ select encode(scol, ecol) from values('hello', 'Windows-xxx') as t(scol, ecol);
select decode();
select decode(encode('abc', 'utf-8'));
select decode(encode('abc', 'utf-8'), 'utf-8');
select decode(encode('大千世界', 'utf-32'), 'utf-32');
select decode(1, 1, 'Southlake');
select decode(2, 1, 'Southlake');
select decode(2, 1, 'Southlake', 2, 'San Francisco', 3, 'New Jersey', 4, 'Seattle', 'Non domestic');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -961,6 +961,14 @@ struct<decode(encode(abc, utf-8), utf-8):string>
abc


-- !query
select decode(encode('大千世界', 'utf-32'), 'utf-32')
-- !query schema
struct<decode(encode(大千世界, utf-32), utf-32):string>
-- !query output
大千世界


-- !query
select decode(1, 1, 'Southlake')
-- !query schema
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -893,6 +893,14 @@ struct<decode(encode(abc, utf-8), utf-8):string>
abc


-- !query
select decode(encode('大千世界', 'utf-32'), 'utf-32')
-- !query schema
struct<decode(encode(大千世界, utf-32), utf-32):string>
-- !query output
大千世界


-- !query
select decode(1, 1, 'Southlake')
-- !query schema
Expand Down

0 comments on commit 9e7debe

Please sign in to comment.