cloud-fan commented on a change in pull request #33707:
URL: https://github.com/apache/spark/pull/33707#discussion_r686938087



##########
File path: sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
##########
@@ -1136,117 +1136,192 @@ struct<INTERVAL '-178956970-8' YEAR TO MONTH:interval 
year to month>
 
 
 -- !query
-create temporary view interval_arithmetic as
-  select CAST(dateval AS date), CAST(tsval AS timestamp), dateval as strval 
from values
-    ('2012-01-01', '2012-01-01')
-    as interval_arithmetic(dateval, tsval)
+select
+  interval '2-2' year to month + interval '3' month,
+  interval '2' year - interval '3-3' year to month,
+  interval '99 11:22:33.123456789' day to second + interval '10 9:8' day to 
minute,
+  interval '22:33.123456789' minute to second - interval '10' day
+-- !query schema
+struct<(INTERVAL '2-2' YEAR TO MONTH + INTERVAL '3' MONTH):interval year to 
month,(INTERVAL '2' YEAR - INTERVAL '3-3' YEAR TO MONTH):interval year to 
month,(INTERVAL '99 11:22:33.123456' DAY TO SECOND + INTERVAL '10 09:08' DAY TO 
MINUTE):interval day to second,(INTERVAL '22:33.123456' MINUTE TO SECOND - 
INTERVAL '10' DAY):interval day to second>
+-- !query output
+2-5    -1-3    109 20:30:33.123456000  -9 23:37:26.876544000
+
+
+-- !query
+select
+  interval '2' year + '3-3 year to month',
+  interval '3 year' - interval '2-2' year to month,
+  interval '99 11:22:33.123456789' day to second + '12:12 hour to second',
+  interval '4 22 day to hour' - interval '10' day,
+  interval '2' year + null,
+  null - interval '4 22' day to hour
 -- !query schema
 struct<>
 -- !query output
+org.apache.spark.sql.catalyst.parser.ParseException
+
+Cannot parse the INTERVAL value: 4 22 day to hour(line 5, pos 2)
 
+== SQL ==
+select
+  interval '2' year + '3-3 year to month',
+  interval '3 year' - interval '2-2' year to month,
+  interval '99 11:22:33.123456789' day to second + '12:12 hour to second',
+  interval '4 22 day to hour' - interval '10' day,
+--^^^
+  interval '2' year + null,
+  null - interval '4 22' day to hour
 
 
 -- !query
-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 interval '2' year + '3-3'
 -- !query schema
-struct<dateval:date,dateval - INTERVAL '2-2' YEAR TO MONTH:date,dateval - 
INTERVAL '-2-2' YEAR TO MONTH:date,dateval + INTERVAL '2-2' YEAR TO 
MONTH:date,dateval + INTERVAL '-2-2' YEAR TO MONTH:date,dateval + (- INTERVAL 
'2-2' YEAR TO MONTH):date,dateval + INTERVAL '2-2' YEAR TO MONTH:date>
+struct<>
 -- !query output
-2012-01-01     2009-11-01      2014-03-01      2014-03-01      2009-11-01      
2009-11-01      2014-03-01
+java.lang.IllegalArgumentException
+Interval string does not match year-month format of `[+|-]d`, `INTERVAL 
[+|-]'[+|-]d' DAY` when cast to interval year: 3-3
 
 
 -- !query
-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' year - '4'
 -- !query schema
-struct<tsval:timestamp,tsval - INTERVAL '2-2' YEAR TO MONTH:timestamp,tsval - 
INTERVAL '-2-2' YEAR TO MONTH:timestamp,tsval + INTERVAL '2-2' YEAR TO 
MONTH:timestamp,tsval + INTERVAL '-2-2' YEAR TO MONTH:timestamp,tsval + (- 
INTERVAL '2-2' YEAR TO MONTH):timestamp,tsval + INTERVAL '2-2' YEAR TO 
MONTH:timestamp>
+struct<(INTERVAL '2' YEAR - 4):interval year>
 -- !query 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
+-2-0
 
 
 -- !query
-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 '4 11:11' - interval '4 22:12' day to minute
 -- !query schema
-struct<(INTERVAL '2-2' YEAR TO MONTH + INTERVAL '3-3' YEAR TO MONTH):interval 
year to month,(INTERVAL '2-2' YEAR TO MONTH - INTERVAL '3-3' YEAR TO 
MONTH):interval year to month>
+struct<>
 -- !query output
-5-5    -1-1
+java.time.DateTimeException
+Cannot cast 4 11:11 to TimestampType.
 
 
 -- !query
-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 '4 12:12:12' + interval '4 22:12' day to minute
 -- !query schema
-struct<dateval:date,dateval - INTERVAL '99 11:22:33.123456' DAY TO 
SECOND:timestamp,dateval - INTERVAL '-99 11:22:33.123456' DAY TO 
SECOND:timestamp,dateval + INTERVAL '99 11:22:33.123456' DAY TO 
SECOND:timestamp,dateval + INTERVAL '-99 11:22:33.123456' DAY TO 
SECOND:timestamp,dateval + (- INTERVAL '99 11:22:33.123456' DAY TO 
SECOND):timestamp,dateval + INTERVAL '99 11:22:33.123456' DAY TO 
SECOND:timestamp>
+struct<>
 -- !query output
-2012-01-01     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
+java.time.DateTimeException
+Cannot cast 4 12:12:12 to TimestampType.

Review comment:
       ditto




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to