-
Notifications
You must be signed in to change notification settings - Fork 28.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
More clear statement on binary comparison expressions. Add some test …
…cases.
- Loading branch information
Showing
3 changed files
with
311 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
sql/core/src/test/resources/sql-tests/inputs/predicate-functions.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
-- In | ||
select 1 in(1, 2, 3); | ||
select 1 in(2, 3, 4); | ||
select named_struct('a', 1, 'b', 2) in(named_struct('a', 1, 'b', 1), named_struct('a', 1, 'b', 3)); | ||
select named_struct('a', 1, 'b', 2) in(named_struct('a', 1, 'b', 2), named_struct('a', 1, 'b', 3)); | ||
|
||
-- EqualTo | ||
select 1 = 1; | ||
select 1 = '1'; | ||
select 1.0 = '1'; | ||
|
||
-- GreaterThan | ||
select 1 > '1'; | ||
select 2 > '1.0'; | ||
select 2 > '2.0'; | ||
select 2 > '2.2'; | ||
select to_date('2009-07-30 04:17:52') > to_date('2009-07-30 04:17:52'); | ||
select to_date('2009-07-30 04:17:52') > '2009-07-30 04:17:52'; | ||
|
||
-- GreaterThanOrEqual | ||
select 1 >= '1'; | ||
select 2 >= '1.0'; | ||
select 2 >= '2.0'; | ||
select 2.0 >= '2.2'; | ||
select to_date('2009-07-30 04:17:52') >= to_date('2009-07-30 04:17:52'); | ||
select to_date('2009-07-30 04:17:52') >= '2009-07-30 04:17:52'; | ||
|
||
-- LessThan | ||
select 1 < '1'; | ||
select 2 < '1.0'; | ||
select 2 < '2.0'; | ||
select 2.0 < '2.2'; | ||
select to_date('2009-07-30 04:17:52') < to_date('2009-07-30 04:17:52'); | ||
select to_date('2009-07-30 04:17:52') < '2009-07-30 04:17:52'; | ||
|
||
-- LessThanOrEqual | ||
select 1 <= '1'; | ||
select 2 <= '1.0'; | ||
select 2 <= '2.0'; | ||
select 2.0 <= '2.2'; | ||
select to_date('2009-07-30 04:17:52') <= to_date('2009-07-30 04:17:52'); | ||
select to_date('2009-07-30 04:17:52') <= '2009-07-30 04:17:52'; |
250 changes: 250 additions & 0 deletions
250
sql/core/src/test/resources/sql-tests/results/predicate-functions.sql.out
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,250 @@ | ||
-- Automatically generated by SQLQueryTestSuite | ||
-- Number of queries: 31 | ||
|
||
|
||
-- !query 0 | ||
select 1 in(1, 2, 3) | ||
-- !query 0 schema | ||
struct<(1 IN (1, 2, 3)):boolean> | ||
-- !query 0 output | ||
true | ||
|
||
|
||
-- !query 1 | ||
select 1 in(2, 3, 4) | ||
-- !query 1 schema | ||
struct<(1 IN (2, 3, 4)):boolean> | ||
-- !query 1 output | ||
false | ||
|
||
|
||
-- !query 2 | ||
select named_struct('a', 1, 'b', 2) in(named_struct('a', 1, 'b', 1), named_struct('a', 1, 'b', 3)) | ||
-- !query 2 schema | ||
struct<(named_struct(a, 1, b, 2) IN (named_struct(a, 1, b, 1), named_struct(a, 1, b, 3))):boolean> | ||
-- !query 2 output | ||
false | ||
|
||
|
||
-- !query 3 | ||
select named_struct('a', 1, 'b', 2) in(named_struct('a', 1, 'b', 2), named_struct('a', 1, 'b', 3)) | ||
-- !query 3 schema | ||
struct<(named_struct(a, 1, b, 2) IN (named_struct(a, 1, b, 2), named_struct(a, 1, b, 3))):boolean> | ||
-- !query 3 output | ||
true | ||
|
||
|
||
-- !query 4 | ||
select 1 = 1 | ||
-- !query 4 schema | ||
struct<(1 = 1):boolean> | ||
-- !query 4 output | ||
true | ||
|
||
|
||
-- !query 5 | ||
select 1 = '1' | ||
-- !query 5 schema | ||
struct<(1 = CAST(1 AS INT)):boolean> | ||
-- !query 5 output | ||
true | ||
|
||
|
||
-- !query 6 | ||
select 1.0 = '1' | ||
-- !query 6 schema | ||
struct<(1.0 = CAST(1 AS DECIMAL(2,1))):boolean> | ||
-- !query 6 output | ||
true | ||
|
||
|
||
-- !query 7 | ||
select 1 > '1' | ||
-- !query 7 schema | ||
struct<(1 > CAST(1 AS INT)):boolean> | ||
-- !query 7 output | ||
false | ||
|
||
|
||
-- !query 8 | ||
select 2 > '1.0' | ||
-- !query 8 schema | ||
struct<(2 > CAST(1.0 AS INT)):boolean> | ||
-- !query 8 output | ||
true | ||
|
||
|
||
-- !query 9 | ||
select 2 > '2.0' | ||
-- !query 9 schema | ||
struct<(2 > CAST(2.0 AS INT)):boolean> | ||
-- !query 9 output | ||
false | ||
|
||
|
||
-- !query 10 | ||
select 2 > '2.2' | ||
-- !query 10 schema | ||
struct<(2 > CAST(2.2 AS INT)):boolean> | ||
-- !query 10 output | ||
false | ||
|
||
|
||
-- !query 11 | ||
select to_date('2009-07-30 04:17:52') > to_date('2009-07-30 04:17:52') | ||
-- !query 11 schema | ||
struct<(to_date('2009-07-30 04:17:52') > to_date('2009-07-30 04:17:52')):boolean> | ||
-- !query 11 output | ||
false | ||
|
||
|
||
-- !query 12 | ||
select to_date('2009-07-30 04:17:52') > '2009-07-30 04:17:52' | ||
-- !query 12 schema | ||
struct<(CAST(to_date('2009-07-30 04:17:52') AS STRING) > 2009-07-30 04:17:52):boolean> | ||
-- !query 12 output | ||
false | ||
|
||
|
||
-- !query 13 | ||
select 1 >= '1' | ||
-- !query 13 schema | ||
struct<(1 >= CAST(1 AS INT)):boolean> | ||
-- !query 13 output | ||
true | ||
|
||
|
||
-- !query 14 | ||
select 2 >= '1.0' | ||
-- !query 14 schema | ||
struct<(2 >= CAST(1.0 AS INT)):boolean> | ||
-- !query 14 output | ||
true | ||
|
||
|
||
-- !query 15 | ||
select 2 >= '2.0' | ||
-- !query 15 schema | ||
struct<(2 >= CAST(2.0 AS INT)):boolean> | ||
-- !query 15 output | ||
true | ||
|
||
|
||
-- !query 16 | ||
select 2.0 >= '2.2' | ||
-- !query 16 schema | ||
struct<(2.0 >= CAST(2.2 AS DECIMAL(2,1))):boolean> | ||
-- !query 16 output | ||
false | ||
|
||
|
||
-- !query 17 | ||
select to_date('2009-07-30 04:17:52') >= to_date('2009-07-30 04:17:52') | ||
-- !query 17 schema | ||
struct<(to_date('2009-07-30 04:17:52') >= to_date('2009-07-30 04:17:52')):boolean> | ||
-- !query 17 output | ||
true | ||
|
||
|
||
-- !query 18 | ||
select to_date('2009-07-30 04:17:52') >= '2009-07-30 04:17:52' | ||
-- !query 18 schema | ||
struct<(CAST(to_date('2009-07-30 04:17:52') AS STRING) >= 2009-07-30 04:17:52):boolean> | ||
-- !query 18 output | ||
false | ||
|
||
|
||
-- !query 19 | ||
select 1 < '1' | ||
-- !query 19 schema | ||
struct<(1 < CAST(1 AS INT)):boolean> | ||
-- !query 19 output | ||
false | ||
|
||
|
||
-- !query 20 | ||
select 2 < '1.0' | ||
-- !query 20 schema | ||
struct<(2 < CAST(1.0 AS INT)):boolean> | ||
-- !query 20 output | ||
false | ||
|
||
|
||
-- !query 21 | ||
select 2 < '2.0' | ||
-- !query 21 schema | ||
struct<(2 < CAST(2.0 AS INT)):boolean> | ||
-- !query 21 output | ||
false | ||
|
||
|
||
-- !query 22 | ||
select 2.0 < '2.2' | ||
-- !query 22 schema | ||
struct<(2.0 < CAST(2.2 AS DECIMAL(2,1))):boolean> | ||
-- !query 22 output | ||
true | ||
|
||
|
||
-- !query 23 | ||
select to_date('2009-07-30 04:17:52') < to_date('2009-07-30 04:17:52') | ||
-- !query 23 schema | ||
struct<(to_date('2009-07-30 04:17:52') < to_date('2009-07-30 04:17:52')):boolean> | ||
-- !query 23 output | ||
false | ||
|
||
|
||
-- !query 24 | ||
select to_date('2009-07-30 04:17:52') < '2009-07-30 04:17:52' | ||
-- !query 24 schema | ||
struct<(CAST(to_date('2009-07-30 04:17:52') AS STRING) < 2009-07-30 04:17:52):boolean> | ||
-- !query 24 output | ||
true | ||
|
||
|
||
-- !query 25 | ||
select 1 <= '1' | ||
-- !query 25 schema | ||
struct<(1 <= CAST(1 AS INT)):boolean> | ||
-- !query 25 output | ||
true | ||
|
||
|
||
-- !query 26 | ||
select 2 <= '1.0' | ||
-- !query 26 schema | ||
struct<(2 <= CAST(1.0 AS INT)):boolean> | ||
-- !query 26 output | ||
false | ||
|
||
|
||
-- !query 27 | ||
select 2 <= '2.0' | ||
-- !query 27 schema | ||
struct<(2 <= CAST(2.0 AS INT)):boolean> | ||
-- !query 27 output | ||
true | ||
|
||
|
||
-- !query 28 | ||
select 2.0 <= '2.2' | ||
-- !query 28 schema | ||
struct<(2.0 <= CAST(2.2 AS DECIMAL(2,1))):boolean> | ||
-- !query 28 output | ||
true | ||
|
||
|
||
-- !query 29 | ||
select to_date('2009-07-30 04:17:52') <= to_date('2009-07-30 04:17:52') | ||
-- !query 29 schema | ||
struct<(to_date('2009-07-30 04:17:52') <= to_date('2009-07-30 04:17:52')):boolean> | ||
-- !query 29 output | ||
true | ||
|
||
|
||
-- !query 30 | ||
select to_date('2009-07-30 04:17:52') <= '2009-07-30 04:17:52' | ||
-- !query 30 schema | ||
struct<(CAST(to_date('2009-07-30 04:17:52') AS STRING) <= 2009-07-30 04:17:52):boolean> | ||
-- !query 30 output | ||
true |