Skip to content
Draft
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
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ CREATE TABLE test_array_min(arr array<int>) USING parquet
statement
INSERT INTO test_array_min VALUES (array(1, 2, 3)), (array(3, 1, 2)), (array()), (NULL), (array(NULL, 1, 2)), (array(-1, -2, -3))

query spark_answer_only
query
SELECT array_min(arr) FROM test_array_min

-- literal arguments
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ CREATE TABLE test_flatten(arr array<array<int>>) USING parquet
statement
INSERT INTO test_flatten VALUES (array(array(1, 2), array(3, 4))), (array(array(), array(1))), (array()), (NULL), (array(array(1, NULL), array(NULL)))

query spark_answer_only
query
SELECT flatten(arr) FROM test_flatten

-- literal arguments
query spark_answer_only
query
SELECT flatten(array(array(1, 2), array(3, 4)))
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ CREATE TABLE test_size(arr array<int>, m map<string, int>) USING parquet
statement
INSERT INTO test_size VALUES (array(1, 2, 3), map('a', 1, 'b', 2)), (array(), map()), (NULL, NULL)

-- size does not support map inputs]
query spark_answer_only
SELECT size(arr), size(m) FROM test_size

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ CREATE TABLE test_bit_get(i int, pos int) USING parquet
statement
INSERT INTO test_bit_get VALUES (11, 0), (11, 1), (11, 2), (11, 3), (0, 0), (NULL, 0), (11, NULL)

query spark_answer_only
query
SELECT bit_get(i, pos) FROM test_bit_get

-- literal arguments
Expand All @@ -74,7 +74,7 @@ SELECT 1111 & 2, 1111 | 2, 1111 ^ 2
query
SELECT bit_count(0), bit_count(7), bit_count(-1)

query spark_answer_only
query
SELECT bit_get(11, 0), bit_get(11, 1), bit_get(11, 2), bit_get(11, 3)

query
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ CREATE TABLE test_unix_date(d date) USING parquet
statement
INSERT INTO test_unix_date VALUES (date('1970-01-01')), (date('2024-01-15')), (date('1969-12-31')), (NULL)

query spark_answer_only
query
SELECT unix_date(d) FROM test_unix_date

-- literal arguments
query spark_answer_only
query
SELECT unix_date(date('1970-01-01')), unix_date(date('2024-01-15')), unix_date(date('1969-12-31')), unix_date(NULL)
30 changes: 15 additions & 15 deletions spark/src/test/resources/sql-tests/expressions/string/right.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,34 +26,34 @@ statement
INSERT INTO test_str_right VALUES ('hello', 3), ('hello', 0), ('hello', -1), ('hello', 10), ('', 3), (NULL, 3), ('hello', NULL)

-- both columns: len must be literal, falls back
query spark_answer_only
query expect_fallback(Substring pos and len must be literals)
SELECT right(s, n) FROM test_str_right

-- column + literal: basic
query spark_answer_only
query
SELECT right(s, 3) FROM test_str_right

-- column + literal: edge cases
query spark_answer_only
query
SELECT right(s, 0) FROM test_str_right

query spark_answer_only
query
SELECT right(s, -1) FROM test_str_right

query spark_answer_only
query
-- n exceeds length of 'hello' (5 chars)
SELECT right(s, 10) FROM test_str_right

-- literal + column: falls back
query spark_answer_only
query expect_fallback(Substring pos and len must be literals)
SELECT right('hello', n) FROM test_str_right

-- literal + literal
query spark_answer_only
query
SELECT right('hello', 3), right('hello', 0), right('hello', -1), right('', 3), right(NULL, 3)

-- null propagation with len <= 0 (critical: NULL str with non-positive len must return NULL, not empty string)
query spark_answer_only
query
SELECT right(CAST(NULL AS STRING), 0), right(CAST(NULL AS STRING), -1), right(CAST(NULL AS STRING), 2)

-- mixed null and non-null values with len <= 0
Expand All @@ -63,17 +63,17 @@ CREATE TABLE test_str_right_nulls(s string) USING parquet
statement
INSERT INTO test_str_right_nulls VALUES ('hello'), (NULL), (''), ('world')

query spark_answer_only
query
SELECT s, right(s, 0) FROM test_str_right_nulls

query spark_answer_only
query
SELECT s, right(s, -1) FROM test_str_right_nulls

query spark_answer_only
query
SELECT s, right(s, 2) FROM test_str_right_nulls

-- equivalence with substring
query spark_answer_only
query
SELECT s, right(s, 3), substring(s, -3, 3) FROM test_str_right_nulls

-- unicode
Expand All @@ -83,11 +83,11 @@ CREATE TABLE test_str_right_unicode(s string) USING parquet
statement
INSERT INTO test_str_right_unicode VALUES ('café'), ('hello世界'), ('😀emoji'), ('తెలుగు'), (NULL)

query spark_answer_only
query
SELECT s, right(s, 2) FROM test_str_right_unicode

query spark_answer_only
query
SELECT s, right(s, 4) FROM test_str_right_unicode

query spark_answer_only
query
SELECT s, right(s, 0) FROM test_str_right_unicode
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ SELECT s RLIKE '^[0-9]+$' FROM test_rlike
query expect_fallback(Regexp pattern)
SELECT s RLIKE '^[a-z]+$' FROM test_rlike

query spark_answer_only
query expect_fallback(Regexp pattern)
SELECT s RLIKE '' FROM test_rlike
Loading