[SPARK-29889][SQL][TEST] unify the interval tests
### What changes were proposed in this pull request? move interval tests to `interval.sql`, and import it to `ansi/interval.sql` ### Why are the changes needed? improve test coverage ### Does this PR introduce any user-facing change? no ### How was this patch tested? N/A Closes #26515 from cloud-fan/test. Authored-by: Wenchen Fan <wenchen@databricks.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This commit is contained in:
parent
d128ef13d8
commit
bb8b04d4a2
|
@ -1,187 +1,17 @@
|
|||
select
|
||||
'1' second,
|
||||
2 seconds,
|
||||
'1' minute,
|
||||
2 minutes,
|
||||
'1' hour,
|
||||
2 hours,
|
||||
'1' day,
|
||||
2 days,
|
||||
'1' month,
|
||||
2 months,
|
||||
'1' year,
|
||||
2 years;
|
||||
|
||||
select
|
||||
interval '10-11' year to month,
|
||||
interval '10' year,
|
||||
interval '11' month;
|
||||
|
||||
select
|
||||
'10-11' year to month,
|
||||
'10' year,
|
||||
'11' month;
|
||||
|
||||
select
|
||||
interval '10 9:8:7.987654321' day to second,
|
||||
interval '10' day,
|
||||
interval '11' hour,
|
||||
interval '12' minute,
|
||||
interval '13' second,
|
||||
interval '13.123456789' second;
|
||||
|
||||
select
|
||||
'10 9:8:7.987654321' day to second,
|
||||
'10' day,
|
||||
'11' hour,
|
||||
'12' minute,
|
||||
'13' second,
|
||||
'13.123456789' second;
|
||||
|
||||
select map(1, interval 1 day, 2, interval 3 week);
|
||||
|
||||
select map(1, 1 day, 2, 3 week);
|
||||
|
||||
-- Interval year-month arithmetic
|
||||
|
||||
create temporary view interval_arithmetic as
|
||||
select CAST(dateval AS date), CAST(tsval AS timestamp) from values
|
||||
('2012-01-01', '2012-01-01')
|
||||
as interval_arithmetic(dateval, tsval);
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '2-2' year to month,
|
||||
dateval - interval '-2-2' year to month,
|
||||
dateval + interval '2-2' year to month,
|
||||
dateval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + dateval,
|
||||
interval '2-2' year to month + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - '2-2' year to month,
|
||||
dateval - '-2-2' year to month,
|
||||
dateval + '2-2' year to month,
|
||||
dateval + '-2-2' year to month,
|
||||
- '2-2' year to month + dateval,
|
||||
'2-2' year to month + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '2-2' year to month,
|
||||
tsval - interval '-2-2' year to month,
|
||||
tsval + interval '2-2' year to month,
|
||||
tsval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + tsval,
|
||||
interval '2-2' year to month + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - '2-2' year to month,
|
||||
tsval - '-2-2' year to month,
|
||||
tsval + '2-2' year to month,
|
||||
tsval + '-2-2' year to month,
|
||||
- '2-2' year to month + tsval,
|
||||
'2-2' year to month + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
interval '2-2' year to month + interval '3-3' year to month,
|
||||
interval '2-2' year to month - interval '3-3' year to month
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
'2-2' year to month + '3-3' year to month,
|
||||
'2-2' year to month - '3-3' year to month
|
||||
from interval_arithmetic;
|
||||
|
||||
-- Interval day-time arithmetic
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '99 11:22:33.123456789' day to second,
|
||||
dateval - interval '-99 11:22:33.123456789' day to second,
|
||||
dateval + interval '99 11:22:33.123456789' day to second,
|
||||
dateval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + dateval,
|
||||
interval '99 11:22:33.123456789' day to second + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - '99 11:22:33.123456789' day to second,
|
||||
dateval - '-99 11:22:33.123456789' day to second,
|
||||
dateval + '99 11:22:33.123456789' day to second,
|
||||
dateval + '-99 11:22:33.123456789' day to second,
|
||||
- '99 11:22:33.123456789' day to second + dateval,
|
||||
'99 11:22:33.123456789' day to second + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '99 11:22:33.123456789' day to second,
|
||||
tsval - interval '-99 11:22:33.123456789' day to second,
|
||||
tsval + interval '99 11:22:33.123456789' day to second,
|
||||
tsval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + tsval,
|
||||
interval '99 11:22:33.123456789' day to second + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - '99 11:22:33.123456789' day to second,
|
||||
tsval - '-99 11:22:33.123456789' day to second,
|
||||
tsval + '99 11:22:33.123456789' day to second,
|
||||
tsval + '-99 11:22:33.123456789' day to second,
|
||||
- '99 11:22:33.123456789' day to second + tsval,
|
||||
'99 11:22:33.123456789' day to second + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
interval '99 11:22:33.123456789' day to second + interval '10 9:8:7.123456789' day to second,
|
||||
interval '99 11:22:33.123456789' day to second - interval '10 9:8:7.123456789' day to second
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
'99 11:22:33.123456789' day to second + '10 9:8:7.123456789' day to second,
|
||||
'99 11:22:33.123456789' day to second - '10 9:8:7.123456789' day to second
|
||||
from interval_arithmetic;
|
||||
|
||||
-- More tests for interval syntax alternatives
|
||||
|
||||
select 30 day;
|
||||
--import interval.sql
|
||||
|
||||
-- the `interval` keyword can be omitted with ansi mode
|
||||
select 1 year 2 days;
|
||||
select '10-9' year to month;
|
||||
select '20 15:40:32.99899999' day to second;
|
||||
select 30 day day;
|
||||
|
||||
select 30 day day day;
|
||||
|
||||
select date '2012-01-01' - 30 day;
|
||||
|
||||
select date '2012-01-01' - 30 day day;
|
||||
|
||||
select date '2012-01-01' - 30 day day day;
|
||||
|
||||
select date '2012-01-01' + '-30' day;
|
||||
|
||||
select date '2012-01-01' + interval '-30' day;
|
||||
|
||||
-- Unsupported syntax for intervals
|
||||
|
||||
select date '2012-01-01' + interval (-30) day;
|
||||
|
||||
select date '2012-01-01' + (-30) day;
|
||||
|
||||
create temporary view t as select * from values (1), (2) as t(a);
|
||||
|
||||
select date '2012-01-01' + interval (a + 1) day from t;
|
||||
|
||||
select date '2012-01-01' + (a + 1) day from t;
|
||||
select date'2012-01-01' - '2-2' year to month;
|
||||
select 1 month - 1 day;
|
||||
|
||||
-- malformed interval literal with ansi mode
|
||||
select 1 year to month;
|
||||
select '1' year to second;
|
||||
select 1 year '2-1' year to month;
|
||||
select (-30) day;
|
||||
select (a + 1) day;
|
||||
select 30 day day day;
|
|
@ -161,67 +161,3 @@ SELECT * FROM (SELECT COUNT(*) AS cnt FROM test_agg) WHERE cnt > 1L;
|
|||
SELECT count(*) FROM test_agg WHERE count(*) > 1L;
|
||||
SELECT count(*) FROM test_agg WHERE count(*) + 1L > 1L;
|
||||
SELECT count(*) FROM test_agg WHERE k = 1 or k = 2 or count(*) + 1L > 1L or max(k) > 1;
|
||||
|
||||
-- sum interval values
|
||||
-- null
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where v is null;
|
||||
|
||||
-- empty set
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0;
|
||||
|
||||
-- basic interval sum
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v);
|
||||
|
||||
-- group by
|
||||
select
|
||||
i,
|
||||
sum(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i;
|
||||
|
||||
-- having
|
||||
select
|
||||
sum(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null;
|
||||
|
||||
-- window
|
||||
SELECT
|
||||
i,
|
||||
Sum(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES(1,'1 seconds'),(1,'2 seconds'),(2,NULL),(2,NULL) t(i,v);
|
||||
|
||||
-- average with interval type
|
||||
-- null
|
||||
select avg(cast(v as interval)) from VALUES (null) t(v);
|
||||
|
||||
-- empty set
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0;
|
||||
|
||||
-- basic interval avg
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v);
|
||||
|
||||
-- group by
|
||||
select
|
||||
i,
|
||||
avg(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i;
|
||||
|
||||
-- having
|
||||
select
|
||||
avg(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null;
|
||||
|
||||
-- window
|
||||
SELECT
|
||||
i,
|
||||
avg(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES (1,'1 seconds'), (1,'2 seconds'), (2,NULL), (2,NULL) t(i,v);
|
||||
|
|
|
@ -53,9 +53,11 @@ select interval '2 seconds' / null;
|
|||
select interval '2 seconds' * null;
|
||||
select null * interval '2 seconds';
|
||||
|
||||
-- interval with a negative sign
|
||||
-- interval with a positive/negative sign
|
||||
select -interval '-1 month 1 day -1 second';
|
||||
select -interval -1 month 1 day -1 second;
|
||||
select +interval '-1 month 1 day -1 second';
|
||||
select +interval -1 month 1 day -1 second;
|
||||
|
||||
-- make intervals
|
||||
select make_interval(1);
|
||||
|
@ -89,7 +91,7 @@ select justify_days(interval '1 month 59 day -25 hour');
|
|||
select justify_hours(interval '1 month 59 day -25 hour');
|
||||
select justify_interval(interval '1 month 59 day -25 hour');
|
||||
|
||||
-- interval
|
||||
-- interval literal
|
||||
select interval 13.123456789 seconds, interval -13.123456789 second;
|
||||
select interval 1 year 2 month 3 week 4 day 5 hour 6 minute 7 seconds 8 millisecond 9 microsecond;
|
||||
select interval '30' year '25' month '-100' day '40' hour '80' minute '299.889987299' second;
|
||||
|
@ -105,6 +107,7 @@ select interval '15:40:32.99899999' hour to second;
|
|||
select interval '20 40:32.99899999' minute to second;
|
||||
select interval '40:32.99899999' minute to second;
|
||||
select interval '40:32' minute to second;
|
||||
select interval 30 day day;
|
||||
|
||||
-- ns is not supported
|
||||
select interval 10 nanoseconds;
|
||||
|
@ -128,6 +131,129 @@ select interval 1 year '2-1' year to month;
|
|||
select interval 1 year '12:11:10' hour to second;
|
||||
select interval '10-9' year to month '1' year;
|
||||
select interval '12:11:10' hour to second '1' year;
|
||||
select interval (-30) day;
|
||||
select interval (a + 1) day;
|
||||
select interval 30 day day day;
|
||||
|
||||
-- awareness of the positive sign before interval type
|
||||
select +interval '1 second';
|
||||
-- sum interval values
|
||||
-- null
|
||||
select sum(cast(null as interval));
|
||||
|
||||
-- empty set
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds') t(v) where 1=0;
|
||||
|
||||
-- basic interval sum
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v);
|
||||
select sum(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v);
|
||||
|
||||
-- group by
|
||||
select
|
||||
i,
|
||||
sum(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i;
|
||||
|
||||
-- having
|
||||
select
|
||||
sum(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null;
|
||||
|
||||
-- window
|
||||
SELECT
|
||||
i,
|
||||
sum(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES(1, '1 seconds'), (1, '2 seconds'), (2, NULL), (2, NULL) t(i,v);
|
||||
|
||||
-- average with interval type
|
||||
-- null
|
||||
select avg(cast(v as interval)) from VALUES (null) t(v);
|
||||
|
||||
-- empty set
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0;
|
||||
|
||||
-- basic interval avg
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v);
|
||||
select avg(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v);
|
||||
|
||||
-- group by
|
||||
select
|
||||
i,
|
||||
avg(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i;
|
||||
|
||||
-- having
|
||||
select
|
||||
avg(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null;
|
||||
|
||||
-- window
|
||||
SELECT
|
||||
i,
|
||||
avg(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES (1,'1 seconds'), (1,'2 seconds'), (2,NULL), (2,NULL) t(i,v);
|
||||
|
||||
-- Interval year-month arithmetic
|
||||
|
||||
create temporary view interval_arithmetic as
|
||||
select CAST(dateval AS date), CAST(tsval AS timestamp) from values
|
||||
('2012-01-01', '2012-01-01')
|
||||
as interval_arithmetic(dateval, tsval);
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '2-2' year to month,
|
||||
dateval - interval '-2-2' year to month,
|
||||
dateval + interval '2-2' year to month,
|
||||
dateval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + dateval,
|
||||
interval '2-2' year to month + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '2-2' year to month,
|
||||
tsval - interval '-2-2' year to month,
|
||||
tsval + interval '2-2' year to month,
|
||||
tsval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + tsval,
|
||||
interval '2-2' year to month + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
interval '2-2' year to month + interval '3-3' year to month,
|
||||
interval '2-2' year to month - interval '3-3' year to month
|
||||
from interval_arithmetic;
|
||||
|
||||
-- Interval day-time arithmetic
|
||||
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '99 11:22:33.123456789' day to second,
|
||||
dateval - interval '-99 11:22:33.123456789' day to second,
|
||||
dateval + interval '99 11:22:33.123456789' day to second,
|
||||
dateval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + dateval,
|
||||
interval '99 11:22:33.123456789' day to second + dateval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '99 11:22:33.123456789' day to second,
|
||||
tsval - interval '-99 11:22:33.123456789' day to second,
|
||||
tsval + interval '99 11:22:33.123456789' day to second,
|
||||
tsval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + tsval,
|
||||
interval '99 11:22:33.123456789' day to second + tsval
|
||||
from interval_arithmetic;
|
||||
|
||||
select
|
||||
interval '99 11:22:33.123456789' day to second + interval '10 9:8:7.123456789' day to second,
|
||||
interval '99 11:22:33.123456789' day to second - interval '10 9:8:7.123456789' day to second
|
||||
from interval_arithmetic;
|
File diff suppressed because it is too large
Load diff
|
@ -1,5 +1,5 @@
|
|||
-- Automatically generated by SQLQueryTestSuite
|
||||
-- Number of queries: 74
|
||||
-- Number of queries: 56
|
||||
|
||||
|
||||
-- !query 0
|
||||
|
@ -573,177 +573,3 @@ org.apache.spark.sql.AnalysisException
|
|||
Aggregate/Window/Generate expressions are not valid in where clause of the query.
|
||||
Expression in where clause: [(((test_agg.`k` = 1) OR (test_agg.`k` = 2)) OR (((count(1) + 1L) > 1L) OR (max(test_agg.`k`) > 1)))]
|
||||
Invalid expressions: [count(1), max(test_agg.`k`)];
|
||||
|
||||
|
||||
-- !query 56
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where v is null
|
||||
-- !query 56 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 56 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 57
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0
|
||||
-- !query 57 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 57 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 58
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 58 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 58 output
|
||||
3 seconds
|
||||
|
||||
|
||||
-- !query 59
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 59 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 59 output
|
||||
1 seconds
|
||||
|
||||
|
||||
-- !query 60
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v)
|
||||
-- !query 60 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 60 output
|
||||
-3 seconds
|
||||
|
||||
|
||||
-- !query 61
|
||||
select sum(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v)
|
||||
-- !query 61 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 61 output
|
||||
-7 days 2 seconds
|
||||
|
||||
|
||||
-- !query 62
|
||||
select
|
||||
i,
|
||||
sum(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i
|
||||
-- !query 62 schema
|
||||
struct<i:int,sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 62 output
|
||||
1 -2 days
|
||||
2 2 seconds
|
||||
3 NULL
|
||||
|
||||
|
||||
-- !query 63
|
||||
select
|
||||
sum(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null
|
||||
-- !query 63 schema
|
||||
struct<sv:interval>
|
||||
-- !query 63 output
|
||||
-2 days 2 seconds
|
||||
|
||||
|
||||
-- !query 64
|
||||
SELECT
|
||||
i,
|
||||
Sum(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES(1,'1 seconds'),(1,'2 seconds'),(2,NULL),(2,NULL) t(i,v)
|
||||
-- !query 64 schema
|
||||
struct<i:int,sum(CAST(v AS INTERVAL)) OVER (ORDER BY i ASC NULLS FIRST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING):interval>
|
||||
-- !query 64 output
|
||||
1 2 seconds
|
||||
1 3 seconds
|
||||
2 NULL
|
||||
2 NULL
|
||||
|
||||
|
||||
-- !query 65
|
||||
select avg(cast(v as interval)) from VALUES (null) t(v)
|
||||
-- !query 65 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 65 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 66
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0
|
||||
-- !query 66 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 66 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 67
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 67 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 67 output
|
||||
1.5 seconds
|
||||
|
||||
|
||||
-- !query 68
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 68 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 68 output
|
||||
0.5 seconds
|
||||
|
||||
|
||||
-- !query 69
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v)
|
||||
-- !query 69 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 69 output
|
||||
-1.5 seconds
|
||||
|
||||
|
||||
-- !query 70
|
||||
select avg(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v)
|
||||
-- !query 70 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 70 output
|
||||
-3 days -11 hours -59 minutes -59 seconds
|
||||
|
||||
|
||||
-- !query 71
|
||||
select
|
||||
i,
|
||||
avg(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i
|
||||
-- !query 71 schema
|
||||
struct<i:int,avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 71 output
|
||||
1 -1 days
|
||||
2 2 seconds
|
||||
3 NULL
|
||||
|
||||
|
||||
-- !query 72
|
||||
select
|
||||
avg(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null
|
||||
-- !query 72 schema
|
||||
struct<sv:interval>
|
||||
-- !query 72 output
|
||||
-15 hours -59 minutes -59.333333 seconds
|
||||
|
||||
|
||||
-- !query 73
|
||||
SELECT
|
||||
i,
|
||||
avg(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES (1,'1 seconds'), (1,'2 seconds'), (2,NULL), (2,NULL) t(i,v)
|
||||
-- !query 73 schema
|
||||
struct<i:int,avg(CAST(v AS INTERVAL)) OVER (ORDER BY i ASC NULLS FIRST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING):interval>
|
||||
-- !query 73 output
|
||||
1 1.5 seconds
|
||||
1 2 seconds
|
||||
2 NULL
|
||||
2 NULL
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
-- Automatically generated by SQLQueryTestSuite
|
||||
-- Number of queries: 88
|
||||
-- Number of queries: 118
|
||||
|
||||
|
||||
-- !query 0
|
||||
|
@ -253,295 +253,295 @@ struct<1 months -1 days 1 seconds:interval>
|
|||
|
||||
|
||||
-- !query 31
|
||||
select make_interval(1)
|
||||
select +interval '-1 month 1 day -1 second'
|
||||
-- !query 31 schema
|
||||
struct<make_interval(1, 0, 0, 0, 0, 0, 0.000000):interval>
|
||||
struct<-1 months 1 days -1 seconds:interval>
|
||||
-- !query 31 output
|
||||
1 years
|
||||
-1 months 1 days -1 seconds
|
||||
|
||||
|
||||
-- !query 32
|
||||
select make_interval(1, 2)
|
||||
select +interval -1 month 1 day -1 second
|
||||
-- !query 32 schema
|
||||
struct<make_interval(1, 2, 0, 0, 0, 0, 0.000000):interval>
|
||||
struct<-1 months 1 days -1 seconds:interval>
|
||||
-- !query 32 output
|
||||
1 years 2 months
|
||||
-1 months 1 days -1 seconds
|
||||
|
||||
|
||||
-- !query 33
|
||||
select make_interval(1, 2, 3)
|
||||
select make_interval(1)
|
||||
-- !query 33 schema
|
||||
struct<make_interval(1, 2, 3, 0, 0, 0, 0.000000):interval>
|
||||
struct<make_interval(1, 0, 0, 0, 0, 0, 0.000000):interval>
|
||||
-- !query 33 output
|
||||
1 years 2 months 21 days
|
||||
1 years
|
||||
|
||||
|
||||
-- !query 34
|
||||
select make_interval(1, 2, 3, 4)
|
||||
select make_interval(1, 2)
|
||||
-- !query 34 schema
|
||||
struct<make_interval(1, 2, 3, 4, 0, 0, 0.000000):interval>
|
||||
struct<make_interval(1, 2, 0, 0, 0, 0, 0.000000):interval>
|
||||
-- !query 34 output
|
||||
1 years 2 months 25 days
|
||||
1 years 2 months
|
||||
|
||||
|
||||
-- !query 35
|
||||
select make_interval(1, 2, 3, 4, 5)
|
||||
select make_interval(1, 2, 3)
|
||||
-- !query 35 schema
|
||||
struct<make_interval(1, 2, 3, 4, 5, 0, 0.000000):interval>
|
||||
struct<make_interval(1, 2, 3, 0, 0, 0, 0.000000):interval>
|
||||
-- !query 35 output
|
||||
1 years 2 months 25 days 5 hours
|
||||
1 years 2 months 21 days
|
||||
|
||||
|
||||
-- !query 36
|
||||
select make_interval(1, 2, 3, 4, 5, 6)
|
||||
select make_interval(1, 2, 3, 4)
|
||||
-- !query 36 schema
|
||||
struct<make_interval(1, 2, 3, 4, 5, 6, 0.000000):interval>
|
||||
struct<make_interval(1, 2, 3, 4, 0, 0, 0.000000):interval>
|
||||
-- !query 36 output
|
||||
1 years 2 months 25 days 5 hours 6 minutes
|
||||
1 years 2 months 25 days
|
||||
|
||||
|
||||
-- !query 37
|
||||
select make_interval(1, 2, 3, 4, 5, 6, 7.008009)
|
||||
select make_interval(1, 2, 3, 4, 5)
|
||||
-- !query 37 schema
|
||||
struct<make_interval(1, 2, 3, 4, 5, 6, CAST(7.008009 AS DECIMAL(8,6))):interval>
|
||||
struct<make_interval(1, 2, 3, 4, 5, 0, 0.000000):interval>
|
||||
-- !query 37 output
|
||||
1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds
|
||||
1 years 2 months 25 days 5 hours
|
||||
|
||||
|
||||
-- !query 38
|
||||
select cast('1 second' as interval)
|
||||
select make_interval(1, 2, 3, 4, 5, 6)
|
||||
-- !query 38 schema
|
||||
struct<CAST(1 second AS INTERVAL):interval>
|
||||
struct<make_interval(1, 2, 3, 4, 5, 6, 0.000000):interval>
|
||||
-- !query 38 output
|
||||
1 seconds
|
||||
1 years 2 months 25 days 5 hours 6 minutes
|
||||
|
||||
|
||||
-- !query 39
|
||||
select cast('+1 second' as interval)
|
||||
select make_interval(1, 2, 3, 4, 5, 6, 7.008009)
|
||||
-- !query 39 schema
|
||||
struct<CAST(+1 second AS INTERVAL):interval>
|
||||
struct<make_interval(1, 2, 3, 4, 5, 6, CAST(7.008009 AS DECIMAL(8,6))):interval>
|
||||
-- !query 39 output
|
||||
1 seconds
|
||||
1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds
|
||||
|
||||
|
||||
-- !query 40
|
||||
select cast('-1 second' as interval)
|
||||
select cast('1 second' as interval)
|
||||
-- !query 40 schema
|
||||
struct<CAST(-1 second AS INTERVAL):interval>
|
||||
struct<CAST(1 second AS INTERVAL):interval>
|
||||
-- !query 40 output
|
||||
-1 seconds
|
||||
1 seconds
|
||||
|
||||
|
||||
-- !query 41
|
||||
select cast('+ 1 second' as interval)
|
||||
select cast('+1 second' as interval)
|
||||
-- !query 41 schema
|
||||
struct<CAST(+ 1 second AS INTERVAL):interval>
|
||||
struct<CAST(+1 second AS INTERVAL):interval>
|
||||
-- !query 41 output
|
||||
1 seconds
|
||||
|
||||
|
||||
-- !query 42
|
||||
select cast('- 1 second' as interval)
|
||||
select cast('-1 second' as interval)
|
||||
-- !query 42 schema
|
||||
struct<CAST(- 1 second AS INTERVAL):interval>
|
||||
struct<CAST(-1 second AS INTERVAL):interval>
|
||||
-- !query 42 output
|
||||
-1 seconds
|
||||
|
||||
|
||||
-- !query 43
|
||||
select cast('- -1 second' as interval)
|
||||
select cast('+ 1 second' as interval)
|
||||
-- !query 43 schema
|
||||
struct<CAST(- -1 second AS INTERVAL):interval>
|
||||
struct<CAST(+ 1 second AS INTERVAL):interval>
|
||||
-- !query 43 output
|
||||
NULL
|
||||
1 seconds
|
||||
|
||||
|
||||
-- !query 44
|
||||
select cast('- +1 second' as interval)
|
||||
select cast('- 1 second' as interval)
|
||||
-- !query 44 schema
|
||||
struct<CAST(- +1 second AS INTERVAL):interval>
|
||||
struct<CAST(- 1 second AS INTERVAL):interval>
|
||||
-- !query 44 output
|
||||
NULL
|
||||
-1 seconds
|
||||
|
||||
|
||||
-- !query 45
|
||||
select justify_days(cast(null as interval))
|
||||
select cast('- -1 second' as interval)
|
||||
-- !query 45 schema
|
||||
struct<justifyDays(CAST(NULL AS INTERVAL)):interval>
|
||||
struct<CAST(- -1 second AS INTERVAL):interval>
|
||||
-- !query 45 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 46
|
||||
select justify_hours(cast(null as interval))
|
||||
select cast('- +1 second' as interval)
|
||||
-- !query 46 schema
|
||||
struct<justifyHours(CAST(NULL AS INTERVAL)):interval>
|
||||
struct<CAST(- +1 second AS INTERVAL):interval>
|
||||
-- !query 46 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 47
|
||||
select justify_interval(cast(null as interval))
|
||||
select justify_days(cast(null as interval))
|
||||
-- !query 47 schema
|
||||
struct<justifyInterval(CAST(NULL AS INTERVAL)):interval>
|
||||
struct<justifyDays(CAST(NULL AS INTERVAL)):interval>
|
||||
-- !query 47 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 48
|
||||
select justify_days(interval '1 month 59 day 25 hour')
|
||||
select justify_hours(cast(null as interval))
|
||||
-- !query 48 schema
|
||||
struct<justifyDays(1 months 59 days 25 hours):interval>
|
||||
struct<justifyHours(CAST(NULL AS INTERVAL)):interval>
|
||||
-- !query 48 output
|
||||
2 months 29 days 25 hours
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 49
|
||||
select justify_hours(interval '1 month 59 day 25 hour')
|
||||
select justify_interval(cast(null as interval))
|
||||
-- !query 49 schema
|
||||
struct<justifyHours(1 months 59 days 25 hours):interval>
|
||||
struct<justifyInterval(CAST(NULL AS INTERVAL)):interval>
|
||||
-- !query 49 output
|
||||
1 months 60 days 1 hours
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 50
|
||||
select justify_interval(interval '1 month 59 day 25 hour')
|
||||
select justify_days(interval '1 month 59 day 25 hour')
|
||||
-- !query 50 schema
|
||||
struct<justifyInterval(1 months 59 days 25 hours):interval>
|
||||
struct<justifyDays(1 months 59 days 25 hours):interval>
|
||||
-- !query 50 output
|
||||
3 months 1 hours
|
||||
2 months 29 days 25 hours
|
||||
|
||||
|
||||
-- !query 51
|
||||
select justify_days(interval '1 month -59 day 25 hour')
|
||||
select justify_hours(interval '1 month 59 day 25 hour')
|
||||
-- !query 51 schema
|
||||
struct<justifyDays(1 months -59 days 25 hours):interval>
|
||||
struct<justifyHours(1 months 59 days 25 hours):interval>
|
||||
-- !query 51 output
|
||||
-29 days 25 hours
|
||||
1 months 60 days 1 hours
|
||||
|
||||
|
||||
-- !query 52
|
||||
select justify_hours(interval '1 month -59 day 25 hour')
|
||||
select justify_interval(interval '1 month 59 day 25 hour')
|
||||
-- !query 52 schema
|
||||
struct<justifyHours(1 months -59 days 25 hours):interval>
|
||||
struct<justifyInterval(1 months 59 days 25 hours):interval>
|
||||
-- !query 52 output
|
||||
1 months -57 days -23 hours
|
||||
3 months 1 hours
|
||||
|
||||
|
||||
-- !query 53
|
||||
select justify_interval(interval '1 month -59 day 25 hour')
|
||||
select justify_days(interval '1 month -59 day 25 hour')
|
||||
-- !query 53 schema
|
||||
struct<justifyInterval(1 months -59 days 25 hours):interval>
|
||||
struct<justifyDays(1 months -59 days 25 hours):interval>
|
||||
-- !query 53 output
|
||||
-27 days -23 hours
|
||||
-29 days 25 hours
|
||||
|
||||
|
||||
-- !query 54
|
||||
select justify_days(interval '1 month 59 day -25 hour')
|
||||
select justify_hours(interval '1 month -59 day 25 hour')
|
||||
-- !query 54 schema
|
||||
struct<justifyDays(1 months 59 days -25 hours):interval>
|
||||
struct<justifyHours(1 months -59 days 25 hours):interval>
|
||||
-- !query 54 output
|
||||
2 months 29 days -25 hours
|
||||
1 months -57 days -23 hours
|
||||
|
||||
|
||||
-- !query 55
|
||||
select justify_hours(interval '1 month 59 day -25 hour')
|
||||
select justify_interval(interval '1 month -59 day 25 hour')
|
||||
-- !query 55 schema
|
||||
struct<justifyHours(1 months 59 days -25 hours):interval>
|
||||
struct<justifyInterval(1 months -59 days 25 hours):interval>
|
||||
-- !query 55 output
|
||||
1 months 57 days 23 hours
|
||||
-27 days -23 hours
|
||||
|
||||
|
||||
-- !query 56
|
||||
select justify_interval(interval '1 month 59 day -25 hour')
|
||||
select justify_days(interval '1 month 59 day -25 hour')
|
||||
-- !query 56 schema
|
||||
struct<justifyInterval(1 months 59 days -25 hours):interval>
|
||||
struct<justifyDays(1 months 59 days -25 hours):interval>
|
||||
-- !query 56 output
|
||||
2 months 27 days 23 hours
|
||||
2 months 29 days -25 hours
|
||||
|
||||
|
||||
-- !query 57
|
||||
select interval 13.123456789 seconds, interval -13.123456789 second
|
||||
select justify_hours(interval '1 month 59 day -25 hour')
|
||||
-- !query 57 schema
|
||||
struct<13.123456 seconds:interval,-13.123456 seconds:interval>
|
||||
struct<justifyHours(1 months 59 days -25 hours):interval>
|
||||
-- !query 57 output
|
||||
13.123456 seconds -13.123456 seconds
|
||||
1 months 57 days 23 hours
|
||||
|
||||
|
||||
-- !query 58
|
||||
select interval 1 year 2 month 3 week 4 day 5 hour 6 minute 7 seconds 8 millisecond 9 microsecond
|
||||
select justify_interval(interval '1 month 59 day -25 hour')
|
||||
-- !query 58 schema
|
||||
struct<1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds:interval>
|
||||
struct<justifyInterval(1 months 59 days -25 hours):interval>
|
||||
-- !query 58 output
|
||||
1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds
|
||||
2 months 27 days 23 hours
|
||||
|
||||
|
||||
-- !query 59
|
||||
select interval '30' year '25' month '-100' day '40' hour '80' minute '299.889987299' second
|
||||
select interval 13.123456789 seconds, interval -13.123456789 second
|
||||
-- !query 59 schema
|
||||
struct<32 years 1 months -100 days 41 hours 24 minutes 59.889987 seconds:interval>
|
||||
struct<13.123456 seconds:interval,-13.123456 seconds:interval>
|
||||
-- !query 59 output
|
||||
32 years 1 months -100 days 41 hours 24 minutes 59.889987 seconds
|
||||
13.123456 seconds -13.123456 seconds
|
||||
|
||||
|
||||
-- !query 60
|
||||
select interval '0 0:0:0.1' day to second
|
||||
select interval 1 year 2 month 3 week 4 day 5 hour 6 minute 7 seconds 8 millisecond 9 microsecond
|
||||
-- !query 60 schema
|
||||
struct<0.1 seconds:interval>
|
||||
struct<1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds:interval>
|
||||
-- !query 60 output
|
||||
0.1 seconds
|
||||
1 years 2 months 25 days 5 hours 6 minutes 7.008009 seconds
|
||||
|
||||
|
||||
-- !query 61
|
||||
select interval '10-9' year to month
|
||||
select interval '30' year '25' month '-100' day '40' hour '80' minute '299.889987299' second
|
||||
-- !query 61 schema
|
||||
struct<10 years 9 months:interval>
|
||||
struct<32 years 1 months -100 days 41 hours 24 minutes 59.889987 seconds:interval>
|
||||
-- !query 61 output
|
||||
10 years 9 months
|
||||
32 years 1 months -100 days 41 hours 24 minutes 59.889987 seconds
|
||||
|
||||
|
||||
-- !query 62
|
||||
select interval '20 15:40:32.99899999' day to hour
|
||||
select interval '0 0:0:0.1' day to second
|
||||
-- !query 62 schema
|
||||
struct<20 days 15 hours:interval>
|
||||
struct<0.1 seconds:interval>
|
||||
-- !query 62 output
|
||||
20 days 15 hours
|
||||
0.1 seconds
|
||||
|
||||
|
||||
-- !query 63
|
||||
select interval '20 15:40:32.99899999' day to minute
|
||||
select interval '10-9' year to month
|
||||
-- !query 63 schema
|
||||
struct<20 days 15 hours 40 minutes:interval>
|
||||
struct<10 years 9 months:interval>
|
||||
-- !query 63 output
|
||||
20 days 15 hours 40 minutes
|
||||
10 years 9 months
|
||||
|
||||
|
||||
-- !query 64
|
||||
select interval '20 15:40:32.99899999' day to second
|
||||
select interval '20 15:40:32.99899999' day to hour
|
||||
-- !query 64 schema
|
||||
struct<20 days 15 hours 40 minutes 32.998999 seconds:interval>
|
||||
struct<20 days 15 hours:interval>
|
||||
-- !query 64 output
|
||||
20 days 15 hours 40 minutes 32.998999 seconds
|
||||
20 days 15 hours
|
||||
|
||||
|
||||
-- !query 65
|
||||
select interval '15:40:32.99899999' hour to minute
|
||||
select interval '20 15:40:32.99899999' day to minute
|
||||
-- !query 65 schema
|
||||
struct<15 hours 40 minutes:interval>
|
||||
struct<20 days 15 hours 40 minutes:interval>
|
||||
-- !query 65 output
|
||||
15 hours 40 minutes
|
||||
20 days 15 hours 40 minutes
|
||||
|
||||
|
||||
-- !query 66
|
||||
select interval '15:40.99899999' hour to second
|
||||
select interval '20 15:40:32.99899999' day to second
|
||||
-- !query 66 schema
|
||||
struct<15 minutes 40.998999 seconds:interval>
|
||||
struct<20 days 15 hours 40 minutes 32.998999 seconds:interval>
|
||||
-- !query 66 output
|
||||
15 minutes 40.998999 seconds
|
||||
20 days 15 hours 40 minutes 32.998999 seconds
|
||||
|
||||
|
||||
-- !query 67
|
||||
select interval '15:40' hour to second
|
||||
select interval '15:40:32.99899999' hour to minute
|
||||
-- !query 67 schema
|
||||
struct<15 hours 40 minutes:interval>
|
||||
-- !query 67 output
|
||||
|
@ -549,42 +549,66 @@ struct<15 hours 40 minutes:interval>
|
|||
|
||||
|
||||
-- !query 68
|
||||
select interval '15:40:32.99899999' hour to second
|
||||
select interval '15:40.99899999' hour to second
|
||||
-- !query 68 schema
|
||||
struct<15 hours 40 minutes 32.998999 seconds:interval>
|
||||
struct<15 minutes 40.998999 seconds:interval>
|
||||
-- !query 68 output
|
||||
15 hours 40 minutes 32.998999 seconds
|
||||
15 minutes 40.998999 seconds
|
||||
|
||||
|
||||
-- !query 69
|
||||
select interval '20 40:32.99899999' minute to second
|
||||
select interval '15:40' hour to second
|
||||
-- !query 69 schema
|
||||
struct<20 days 40 minutes 32.998999 seconds:interval>
|
||||
struct<15 hours 40 minutes:interval>
|
||||
-- !query 69 output
|
||||
20 days 40 minutes 32.998999 seconds
|
||||
15 hours 40 minutes
|
||||
|
||||
|
||||
-- !query 70
|
||||
select interval '40:32.99899999' minute to second
|
||||
select interval '15:40:32.99899999' hour to second
|
||||
-- !query 70 schema
|
||||
struct<40 minutes 32.998999 seconds:interval>
|
||||
struct<15 hours 40 minutes 32.998999 seconds:interval>
|
||||
-- !query 70 output
|
||||
40 minutes 32.998999 seconds
|
||||
15 hours 40 minutes 32.998999 seconds
|
||||
|
||||
|
||||
-- !query 71
|
||||
select interval '40:32' minute to second
|
||||
select interval '20 40:32.99899999' minute to second
|
||||
-- !query 71 schema
|
||||
struct<40 minutes 32 seconds:interval>
|
||||
struct<20 days 40 minutes 32.998999 seconds:interval>
|
||||
-- !query 71 output
|
||||
40 minutes 32 seconds
|
||||
20 days 40 minutes 32.998999 seconds
|
||||
|
||||
|
||||
-- !query 72
|
||||
select interval 10 nanoseconds
|
||||
select interval '40:32.99899999' minute to second
|
||||
-- !query 72 schema
|
||||
struct<>
|
||||
struct<40 minutes 32.998999 seconds:interval>
|
||||
-- !query 72 output
|
||||
40 minutes 32.998999 seconds
|
||||
|
||||
|
||||
-- !query 73
|
||||
select interval '40:32' minute to second
|
||||
-- !query 73 schema
|
||||
struct<40 minutes 32 seconds:interval>
|
||||
-- !query 73 output
|
||||
40 minutes 32 seconds
|
||||
|
||||
|
||||
-- !query 74
|
||||
select interval 30 day day
|
||||
-- !query 74 schema
|
||||
struct<day:interval>
|
||||
-- !query 74 output
|
||||
30 days
|
||||
|
||||
|
||||
-- !query 75
|
||||
select interval 10 nanoseconds
|
||||
-- !query 75 schema
|
||||
struct<>
|
||||
-- !query 75 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
no viable alternative at input '10 nanoseconds'(line 1, pos 19)
|
||||
|
@ -594,35 +618,35 @@ select interval 10 nanoseconds
|
|||
-------------------^^^
|
||||
|
||||
|
||||
-- !query 73
|
||||
-- !query 76
|
||||
select map(1, interval 1 day, 2, interval 3 week)
|
||||
-- !query 73 schema
|
||||
-- !query 76 schema
|
||||
struct<map(1, 1 days, 2, 21 days):map<int,interval>>
|
||||
-- !query 73 output
|
||||
-- !query 76 output
|
||||
{1:1 days,2:21 days}
|
||||
|
||||
|
||||
-- !query 74
|
||||
-- !query 77
|
||||
select interval 'interval 3 year 1 hour'
|
||||
-- !query 74 schema
|
||||
-- !query 77 schema
|
||||
struct<3 years 1 hours:interval>
|
||||
-- !query 74 output
|
||||
-- !query 77 output
|
||||
3 years 1 hours
|
||||
|
||||
|
||||
-- !query 75
|
||||
-- !query 78
|
||||
select interval '3 year 1 hour'
|
||||
-- !query 75 schema
|
||||
-- !query 78 schema
|
||||
struct<3 years 1 hours:interval>
|
||||
-- !query 75 output
|
||||
-- !query 78 output
|
||||
3 years 1 hours
|
||||
|
||||
|
||||
-- !query 76
|
||||
-- !query 79
|
||||
select interval
|
||||
-- !query 76 schema
|
||||
-- !query 79 schema
|
||||
struct<>
|
||||
-- !query 76 output
|
||||
-- !query 79 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
at least one time unit should be given for interval literal(line 1, pos 7)
|
||||
|
@ -632,11 +656,11 @@ select interval
|
|||
-------^^^
|
||||
|
||||
|
||||
-- !query 77
|
||||
-- !query 80
|
||||
select interval 1 fake_unit
|
||||
-- !query 77 schema
|
||||
-- !query 80 schema
|
||||
struct<>
|
||||
-- !query 77 output
|
||||
-- !query 80 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
no viable alternative at input '1 fake_unit'(line 1, pos 18)
|
||||
|
@ -646,11 +670,11 @@ select interval 1 fake_unit
|
|||
------------------^^^
|
||||
|
||||
|
||||
-- !query 78
|
||||
-- !query 81
|
||||
select interval 1 year to month
|
||||
-- !query 78 schema
|
||||
-- !query 81 schema
|
||||
struct<>
|
||||
-- !query 78 output
|
||||
-- !query 81 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
The value of from-to unit must be a string(line 1, pos 16)
|
||||
|
@ -660,11 +684,11 @@ select interval 1 year to month
|
|||
----------------^^^
|
||||
|
||||
|
||||
-- !query 79
|
||||
-- !query 82
|
||||
select interval '1' year to second
|
||||
-- !query 79 schema
|
||||
-- !query 82 schema
|
||||
struct<>
|
||||
-- !query 79 output
|
||||
-- !query 82 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Intervals FROM year TO second are not supported.(line 1, pos 16)
|
||||
|
@ -674,11 +698,11 @@ select interval '1' year to second
|
|||
----------------^^^
|
||||
|
||||
|
||||
-- !query 80
|
||||
-- !query 83
|
||||
select interval '10-9' year to month '2-1' year to month
|
||||
-- !query 80 schema
|
||||
-- !query 83 schema
|
||||
struct<>
|
||||
-- !query 80 output
|
||||
-- !query 83 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 37)
|
||||
|
@ -688,11 +712,11 @@ select interval '10-9' year to month '2-1' year to month
|
|||
-------------------------------------^^^
|
||||
|
||||
|
||||
-- !query 81
|
||||
-- !query 84
|
||||
select interval '10-9' year to month '12:11:10' hour to second
|
||||
-- !query 81 schema
|
||||
-- !query 84 schema
|
||||
struct<>
|
||||
-- !query 81 output
|
||||
-- !query 84 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 37)
|
||||
|
@ -702,11 +726,11 @@ select interval '10-9' year to month '12:11:10' hour to second
|
|||
-------------------------------------^^^
|
||||
|
||||
|
||||
-- !query 82
|
||||
-- !query 85
|
||||
select interval '1 15:11' day to minute '12:11:10' hour to second
|
||||
-- !query 82 schema
|
||||
-- !query 85 schema
|
||||
struct<>
|
||||
-- !query 82 output
|
||||
-- !query 85 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 40)
|
||||
|
@ -716,11 +740,11 @@ select interval '1 15:11' day to minute '12:11:10' hour to second
|
|||
----------------------------------------^^^
|
||||
|
||||
|
||||
-- !query 83
|
||||
-- !query 86
|
||||
select interval 1 year '2-1' year to month
|
||||
-- !query 83 schema
|
||||
-- !query 86 schema
|
||||
struct<>
|
||||
-- !query 83 output
|
||||
-- !query 86 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 23)
|
||||
|
@ -730,11 +754,11 @@ select interval 1 year '2-1' year to month
|
|||
-----------------------^^^
|
||||
|
||||
|
||||
-- !query 84
|
||||
-- !query 87
|
||||
select interval 1 year '12:11:10' hour to second
|
||||
-- !query 84 schema
|
||||
-- !query 87 schema
|
||||
struct<>
|
||||
-- !query 84 output
|
||||
-- !query 87 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 23)
|
||||
|
@ -744,11 +768,11 @@ select interval 1 year '12:11:10' hour to second
|
|||
-----------------------^^^
|
||||
|
||||
|
||||
-- !query 85
|
||||
-- !query 88
|
||||
select interval '10-9' year to month '1' year
|
||||
-- !query 85 schema
|
||||
-- !query 88 schema
|
||||
struct<>
|
||||
-- !query 85 output
|
||||
-- !query 88 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 37)
|
||||
|
@ -758,11 +782,11 @@ select interval '10-9' year to month '1' year
|
|||
-------------------------------------^^^
|
||||
|
||||
|
||||
-- !query 86
|
||||
-- !query 89
|
||||
select interval '12:11:10' hour to second '1' year
|
||||
-- !query 86 schema
|
||||
-- !query 89 schema
|
||||
struct<>
|
||||
-- !query 86 output
|
||||
-- !query 89 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
Can only have a single from-to unit in the interval literal syntax(line 1, pos 42)
|
||||
|
@ -772,9 +796,304 @@ select interval '12:11:10' hour to second '1' year
|
|||
------------------------------------------^^^
|
||||
|
||||
|
||||
-- !query 87
|
||||
select +interval '1 second'
|
||||
-- !query 87 schema
|
||||
struct<1 seconds:interval>
|
||||
-- !query 87 output
|
||||
-- !query 90
|
||||
select interval (-30) day
|
||||
-- !query 90 schema
|
||||
struct<>
|
||||
-- !query 90 output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
Undefined function: 'interval'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7
|
||||
|
||||
|
||||
-- !query 91
|
||||
select interval (a + 1) day
|
||||
-- !query 91 schema
|
||||
struct<>
|
||||
-- !query 91 output
|
||||
org.apache.spark.sql.AnalysisException
|
||||
Undefined function: 'interval'. This function is neither a registered temporary function nor a permanent function registered in the database 'default'.; line 1 pos 7
|
||||
|
||||
|
||||
-- !query 92
|
||||
select interval 30 day day day
|
||||
-- !query 92 schema
|
||||
struct<>
|
||||
-- !query 92 output
|
||||
org.apache.spark.sql.catalyst.parser.ParseException
|
||||
|
||||
extraneous input 'day' expecting <EOF>(line 1, pos 27)
|
||||
|
||||
== SQL ==
|
||||
select interval 30 day day day
|
||||
---------------------------^^^
|
||||
|
||||
|
||||
-- !query 93
|
||||
select sum(cast(null as interval))
|
||||
-- !query 93 schema
|
||||
struct<sum(CAST(NULL AS INTERVAL)):interval>
|
||||
-- !query 93 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 94
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds') t(v) where 1=0
|
||||
-- !query 94 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 94 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 95
|
||||
select sum(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 95 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 95 output
|
||||
3 seconds
|
||||
|
||||
|
||||
-- !query 96
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 96 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 96 output
|
||||
1 seconds
|
||||
|
||||
|
||||
-- !query 97
|
||||
select sum(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v)
|
||||
-- !query 97 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 97 output
|
||||
-3 seconds
|
||||
|
||||
|
||||
-- !query 98
|
||||
select sum(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v)
|
||||
-- !query 98 schema
|
||||
struct<sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 98 output
|
||||
-7 days 2 seconds
|
||||
|
||||
|
||||
-- !query 99
|
||||
select
|
||||
i,
|
||||
sum(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i
|
||||
-- !query 99 schema
|
||||
struct<i:int,sum(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 99 output
|
||||
1 -2 days
|
||||
2 2 seconds
|
||||
3 NULL
|
||||
|
||||
|
||||
-- !query 100
|
||||
select
|
||||
sum(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null
|
||||
-- !query 100 schema
|
||||
struct<sv:interval>
|
||||
-- !query 100 output
|
||||
-2 days 2 seconds
|
||||
|
||||
|
||||
-- !query 101
|
||||
SELECT
|
||||
i,
|
||||
sum(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES(1, '1 seconds'), (1, '2 seconds'), (2, NULL), (2, NULL) t(i,v)
|
||||
-- !query 101 schema
|
||||
struct<i:int,sum(CAST(v AS INTERVAL)) OVER (ORDER BY i ASC NULLS FIRST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING):interval>
|
||||
-- !query 101 output
|
||||
1 2 seconds
|
||||
1 3 seconds
|
||||
2 NULL
|
||||
2 NULL
|
||||
|
||||
|
||||
-- !query 102
|
||||
select avg(cast(v as interval)) from VALUES (null) t(v)
|
||||
-- !query 102 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 102 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 103
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v) where 1=0
|
||||
-- !query 103 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 103 output
|
||||
NULL
|
||||
|
||||
|
||||
-- !query 104
|
||||
select avg(cast(v as interval)) from VALUES ('1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 104 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 104 output
|
||||
1.5 seconds
|
||||
|
||||
|
||||
-- !query 105
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('2 seconds'), (null) t(v)
|
||||
-- !query 105 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 105 output
|
||||
0.5 seconds
|
||||
|
||||
|
||||
-- !query 106
|
||||
select avg(cast(v as interval)) from VALUES ('-1 seconds'), ('-2 seconds'), (null) t(v)
|
||||
-- !query 106 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 106 output
|
||||
-1.5 seconds
|
||||
|
||||
|
||||
-- !query 107
|
||||
select avg(cast(v as interval)) from VALUES ('-1 weeks'), ('2 seconds'), (null) t(v)
|
||||
-- !query 107 schema
|
||||
struct<avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 107 output
|
||||
-3 days -11 hours -59 minutes -59 seconds
|
||||
|
||||
|
||||
-- !query 108
|
||||
select
|
||||
i,
|
||||
avg(cast(v as interval))
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
group by i
|
||||
-- !query 108 schema
|
||||
struct<i:int,avg(CAST(v AS INTERVAL)):interval>
|
||||
-- !query 108 output
|
||||
1 -1 days
|
||||
2 2 seconds
|
||||
3 NULL
|
||||
|
||||
|
||||
-- !query 109
|
||||
select
|
||||
avg(cast(v as interval)) as sv
|
||||
from VALUES (1, '-1 weeks'), (2, '2 seconds'), (3, null), (1, '5 days') t(i, v)
|
||||
having sv is not null
|
||||
-- !query 109 schema
|
||||
struct<sv:interval>
|
||||
-- !query 109 output
|
||||
-15 hours -59 minutes -59.333333 seconds
|
||||
|
||||
|
||||
-- !query 110
|
||||
SELECT
|
||||
i,
|
||||
avg(cast(v as interval)) OVER (ORDER BY i ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING)
|
||||
FROM VALUES (1,'1 seconds'), (1,'2 seconds'), (2,NULL), (2,NULL) t(i,v)
|
||||
-- !query 110 schema
|
||||
struct<i:int,avg(CAST(v AS INTERVAL)) OVER (ORDER BY i ASC NULLS FIRST ROWS BETWEEN CURRENT ROW AND UNBOUNDED FOLLOWING):interval>
|
||||
-- !query 110 output
|
||||
1 1.5 seconds
|
||||
1 2 seconds
|
||||
2 NULL
|
||||
2 NULL
|
||||
|
||||
|
||||
-- !query 111
|
||||
create temporary view interval_arithmetic as
|
||||
select CAST(dateval AS date), CAST(tsval AS timestamp) from values
|
||||
('2012-01-01', '2012-01-01')
|
||||
as interval_arithmetic(dateval, tsval)
|
||||
-- !query 111 schema
|
||||
struct<>
|
||||
-- !query 111 output
|
||||
|
||||
|
||||
|
||||
-- !query 112
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '2-2' year to month,
|
||||
dateval - interval '-2-2' year to month,
|
||||
dateval + interval '2-2' year to month,
|
||||
dateval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + dateval,
|
||||
interval '2-2' year to month + dateval
|
||||
from interval_arithmetic
|
||||
-- !query 112 schema
|
||||
struct<dateval:date,CAST(CAST(dateval AS TIMESTAMP) - 2 years 2 months AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) - -2 years -2 months AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + 2 years 2 months AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + -2 years -2 months AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + -2 years -2 months AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + 2 years 2 months AS DATE):date>
|
||||
-- !query 112 output
|
||||
2012-01-01 2009-11-01 2014-03-01 2014-03-01 2009-11-01 2009-11-01 2014-03-01
|
||||
|
||||
|
||||
-- !query 113
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '2-2' year to month,
|
||||
tsval - interval '-2-2' year to month,
|
||||
tsval + interval '2-2' year to month,
|
||||
tsval + interval '-2-2' year to month,
|
||||
- interval '2-2' year to month + tsval,
|
||||
interval '2-2' year to month + tsval
|
||||
from interval_arithmetic
|
||||
-- !query 113 schema
|
||||
struct<tsval:timestamp,CAST(tsval - 2 years 2 months AS TIMESTAMP):timestamp,CAST(tsval - -2 years -2 months AS TIMESTAMP):timestamp,CAST(tsval + 2 years 2 months AS TIMESTAMP):timestamp,CAST(tsval + -2 years -2 months AS TIMESTAMP):timestamp,CAST(tsval + -2 years -2 months AS TIMESTAMP):timestamp,CAST(tsval + 2 years 2 months AS TIMESTAMP):timestamp>
|
||||
-- !query 113 output
|
||||
2012-01-01 00:00:00 2009-11-01 00:00:00 2014-03-01 00:00:00 2014-03-01 00:00:00 2009-11-01 00:00:00 2009-11-01 00:00:00 2014-03-01 00:00:00
|
||||
|
||||
|
||||
-- !query 114
|
||||
select
|
||||
interval '2-2' year to month + interval '3-3' year to month,
|
||||
interval '2-2' year to month - interval '3-3' year to month
|
||||
from interval_arithmetic
|
||||
-- !query 114 schema
|
||||
struct<(2 years 2 months + 3 years 3 months):interval,(2 years 2 months - 3 years 3 months):interval>
|
||||
-- !query 114 output
|
||||
5 years 5 months -1 years -1 months
|
||||
|
||||
|
||||
-- !query 115
|
||||
select
|
||||
dateval,
|
||||
dateval - interval '99 11:22:33.123456789' day to second,
|
||||
dateval - interval '-99 11:22:33.123456789' day to second,
|
||||
dateval + interval '99 11:22:33.123456789' day to second,
|
||||
dateval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + dateval,
|
||||
interval '99 11:22:33.123456789' day to second + dateval
|
||||
from interval_arithmetic
|
||||
-- !query 115 schema
|
||||
struct<dateval:date,CAST(CAST(dateval AS TIMESTAMP) - 99 days 11 hours 22 minutes 33.123456 seconds AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) - -99 days -11 hours -22 minutes -33.123456 seconds AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + 99 days 11 hours 22 minutes 33.123456 seconds AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + -99 days -11 hours -22 minutes -33.123456 seconds AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + -99 days -11 hours -22 minutes -33.123456 seconds AS DATE):date,CAST(CAST(dateval AS TIMESTAMP) + 99 days 11 hours 22 minutes 33.123456 seconds AS DATE):date>
|
||||
-- !query 115 output
|
||||
2012-01-01 2011-09-23 2012-04-09 2012-04-09 2011-09-23 2011-09-23 2012-04-09
|
||||
|
||||
|
||||
-- !query 116
|
||||
select
|
||||
tsval,
|
||||
tsval - interval '99 11:22:33.123456789' day to second,
|
||||
tsval - interval '-99 11:22:33.123456789' day to second,
|
||||
tsval + interval '99 11:22:33.123456789' day to second,
|
||||
tsval + interval '-99 11:22:33.123456789' day to second,
|
||||
-interval '99 11:22:33.123456789' day to second + tsval,
|
||||
interval '99 11:22:33.123456789' day to second + tsval
|
||||
from interval_arithmetic
|
||||
-- !query 116 schema
|
||||
struct<tsval:timestamp,CAST(tsval - 99 days 11 hours 22 minutes 33.123456 seconds AS TIMESTAMP):timestamp,CAST(tsval - -99 days -11 hours -22 minutes -33.123456 seconds AS TIMESTAMP):timestamp,CAST(tsval + 99 days 11 hours 22 minutes 33.123456 seconds AS TIMESTAMP):timestamp,CAST(tsval + -99 days -11 hours -22 minutes -33.123456 seconds AS TIMESTAMP):timestamp,CAST(tsval + -99 days -11 hours -22 minutes -33.123456 seconds AS TIMESTAMP):timestamp,CAST(tsval + 99 days 11 hours 22 minutes 33.123456 seconds AS TIMESTAMP):timestamp>
|
||||
-- !query 116 output
|
||||
2012-01-01 00:00:00 2011-09-23 12:37:26.876544 2012-04-09 11:22:33.123456 2012-04-09 11:22:33.123456 2011-09-23 12:37:26.876544 2011-09-23 12:37:26.876544 2012-04-09 11:22:33.123456
|
||||
|
||||
|
||||
-- !query 117
|
||||
select
|
||||
interval '99 11:22:33.123456789' day to second + interval '10 9:8:7.123456789' day to second,
|
||||
interval '99 11:22:33.123456789' day to second - interval '10 9:8:7.123456789' day to second
|
||||
from interval_arithmetic
|
||||
-- !query 117 schema
|
||||
struct<(99 days 11 hours 22 minutes 33.123456 seconds + 10 days 9 hours 8 minutes 7.123456 seconds):interval,(99 days 11 hours 22 minutes 33.123456 seconds - 10 days 9 hours 8 minutes 7.123456 seconds):interval>
|
||||
-- !query 117 output
|
||||
109 days 20 hours 30 minutes 40.246912 seconds 89 days 2 hours 14 minutes 26 seconds
|
||||
|
|
Loading…
Reference in a new issue