This is an automated email from the ASF dual-hosted git repository.
maxgekk pushed a commit to branch branch-3.2
in repository https://gitbox.apache.org/repos/asf/spark.git
The following commit(s) were added to refs/heads/branch-3.2 by this push:
new eaf92be [SPARK-36499][SQL][TESTS] Test Interval multiply / divide null
eaf92be is described below
commit eaf92bea99d1a6f4661718c484d167c7a08a37f6
Author: Gengliang Wang <[email protected]>
AuthorDate: Fri Aug 13 11:05:57 2021 +0300
[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 <[email protected]>
Signed-off-by: Max Gekk <[email protected]>
(cherry picked from commit eb6be7f1ee076aeaa312f7a3ff0c88db516b793b)
Signed-off-by: Max Gekk <[email protected]>
---
.../test/resources/sql-tests/inputs/interval.sql | 11 ++++
.../sql-tests/results/ansi/interval.sql.out | 71 +++++++++++++++++++++-
.../resources/sql-tests/results/interval.sql.out | 71 +++++++++++++++++++++-
3 files changed, 151 insertions(+), 2 deletions(-)
diff --git a/sql/core/src/test/resources/sql-tests/inputs/interval.sql
b/sql/core/src/test/resources/sql-tests/inputs/interval.sql
index 80df45d..be13a25 100644
--- a/sql/core/src/test/resources/sql-tests/inputs/interval.sql
+++ b/sql/core/src/test/resources/sql-tests/inputs/interval.sql
@@ -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';
diff --git
a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
index b048105..4e784b0 100644
--- a/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
--- Number of queries: 223
+-- Number of queries: 231
-- !query
@@ -118,6 +118,75 @@ 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
struct<>
diff --git a/sql/core/src/test/resources/sql-tests/results/interval.sql.out
b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
index 2391b8a..a6e2599 100644
--- a/sql/core/src/test/resources/sql-tests/results/interval.sql.out
+++ b/sql/core/src/test/resources/sql-tests/results/interval.sql.out
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
--- Number of queries: 223
+-- Number of queries: 231
-- !query
@@ -118,6 +118,75 @@ 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
struct<>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]