[SPARK-36499][SQL][TESTS] Test Interval multiply / divide null
### What changes were proposed in this pull request? Test the following valid operations: ``` year-month interval * null null * year-month interval year-month interval / null ``` and invalid operations: ``` null / interval int / interval ``` ### Why are the changes needed? Improve test coverage ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass CI Closes #33729 from gengliangwang/addTest. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Max Gekk <max.gekk@gmail.com>
This commit is contained in:
parent
7d82336734
commit
eb6be7f1ee
|
@ -16,6 +16,16 @@ select interval '2 seconds' / 0;
|
|||
select interval '2 seconds' / null;
|
||||
select interval '2 seconds' * null;
|
||||
select null * interval '2 seconds';
|
||||
select interval '2' year / 0;
|
||||
select interval '2' year / null;
|
||||
select interval '2' year * null;
|
||||
select null * interval '2' year;
|
||||
|
||||
-- invalid: divide by interval
|
||||
select 2 / interval '2' year;
|
||||
select 2 / interval '2' hour;
|
||||
select null / interval '2' year;
|
||||
select null / interval '2' hour;
|
||||
|
||||
-- interval with a positive/negative sign
|
||||
select -interval '-1 month 1 day -1 second';
|
||||
|
@ -170,6 +180,7 @@ select
|
|||
null - interval '2' year,
|
||||
null + interval '2' hour,
|
||||
null - interval '2' hour;
|
||||
|
||||
-- invalid: malformed interval string
|
||||
select interval '2' year + '3-3';
|
||||
select interval '2' year - '4';
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- Automatically generated by SQLQueryTestSuite
|
||||
-- Number of queries: 223
|
||||
-- Number of queries: 231
|
||||
|
||||
|
||||
-- !query
|
||||
|
@ -117,6 +117,75 @@ struct<(INTERVAL '02' SECOND * NULL):interval day to second>
|
|||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year / 0
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
java.lang.ArithmeticException
|
||||
/ by zero
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year / null
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR / NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year * null
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR * NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select null * interval '2' year
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR * NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select 2 / interval '2' year
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(2 / INTERVAL '2' YEAR)' due to data type mismatch: differing types in '(2 / INTERVAL '2' YEAR)' (int and interval year).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select 2 / interval '2' hour
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(2 / INTERVAL '02' HOUR)' due to data type mismatch: differing types in '(2 / INTERVAL '02' HOUR)' (int and interval hour).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select null / interval '2' year
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(NULL / INTERVAL '2' YEAR)' due to data type mismatch: differing types in '(NULL / INTERVAL '2' YEAR)' (void and interval year).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select null / interval '2' hour
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(NULL / INTERVAL '02' HOUR)' due to data type mismatch: differing types in '(NULL / INTERVAL '02' HOUR)' (void and interval hour).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select -interval '-1 month 1 day -1 second'
|
||||
-- !query schema
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- Automatically generated by SQLQueryTestSuite
|
||||
-- Number of queries: 223
|
||||
-- Number of queries: 231
|
||||
|
||||
|
||||
-- !query
|
||||
|
@ -117,6 +117,75 @@ struct<(INTERVAL '02' SECOND * NULL):interval day to second>
|
|||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year / 0
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
java.lang.ArithmeticException
|
||||
/ by zero
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year / null
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR / NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select interval '2' year * null
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR * NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select null * interval '2' year
|
||||
-- !query schema
|
||||
struct<(INTERVAL '2' YEAR * NULL):interval year to month>
|
||||
-- !query output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query
|
||||
select 2 / interval '2' year
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(2 / INTERVAL '2' YEAR)' due to data type mismatch: differing types in '(2 / INTERVAL '2' YEAR)' (int and interval year).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select 2 / interval '2' hour
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(2 / INTERVAL '02' HOUR)' due to data type mismatch: differing types in '(2 / INTERVAL '02' HOUR)' (int and interval hour).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select null / interval '2' year
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(NULL / INTERVAL '2' YEAR)' due to data type mismatch: differing types in '(NULL / INTERVAL '2' YEAR)' (void and interval year).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select null / interval '2' hour
|
||||
-- !query schema
|
||||
struct<>
|
||||
-- !query output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
cannot resolve '(NULL / INTERVAL '02' HOUR)' due to data type mismatch: differing types in '(NULL / INTERVAL '02' HOUR)' (void and interval hour).; line 1 pos 7
|
||||
|
||||
|
||||
-- !query
|
||||
select -interval '-1 month 1 day -1 second'
|
||||
-- !query schema
|
||||
|
|
Loading…
Reference in a new issue