cloud-fan commented on a change in pull request #33707:
URL: https://github.com/apache/spark/pull/33707#discussion_r686945524
##########
File path: sql/core/src/test/resources/sql-tests/results/ansi/timestamp.sql.out
##########
@@ -533,136 +533,145 @@ struct<to_timestamp(2019 10:10:10, yyyy
hh:mm:ss):timestamp>
-- !query
-select timestamp'2011-11-11 11:11:11' + interval '2' day
+select timestamp'2011-11-11 11:11:11' - timestamp'2011-11-11 11:11:10'
-- !query schema
-struct<TIMESTAMP '2011-11-11 11:11:11' + INTERVAL '2' DAY:timestamp>
+struct<(TIMESTAMP '2011-11-11 11:11:11' - TIMESTAMP '2011-11-11
11:11:10'):interval day to second>
-- !query output
-2011-11-13 11:11:11
+0 00:00:01.000000000
-- !query
-select timestamp'2011-11-11 11:11:11' - interval '2' day
+select date'2020-01-01' - timestamp'2019-10-06 10:11:12.345678'
-- !query schema
-struct<TIMESTAMP '2011-11-11 11:11:11' - INTERVAL '2' DAY:timestamp>
+struct<(DATE '2020-01-01' - TIMESTAMP '2019-10-06 10:11:12.345678'):interval
day to second>
-- !query output
-2011-11-09 11:11:11
+86 13:48:47.654322000
-- !query
-select timestamp'2011-11-11 11:11:11' + interval '2' second
+select timestamp'2019-10-06 10:11:12.345678' - date'2020-01-01'
-- !query schema
-struct<TIMESTAMP '2011-11-11 11:11:11' + INTERVAL '02' SECOND:timestamp>
+struct<(TIMESTAMP '2019-10-06 10:11:12.345678' - DATE '2020-01-01'):interval
day to second>
-- !query output
-2011-11-11 11:11:13
+-86 13:48:47.654322000
-- !query
-select timestamp'2011-11-11 11:11:11' - interval '2' second
+select timestamp'2011-11-11 11:11:11' - '2011-11-11 11:11:10'
-- !query schema
-struct<TIMESTAMP '2011-11-11 11:11:11' - INTERVAL '02' SECOND:timestamp>
+struct<>
-- !query output
-2011-11-11 11:11:09
+org.apache.spark.sql.AnalysisException
+cannot resolve '(TIMESTAMP '2011-11-11 11:11:11' - '2011-11-11 11:11:10')' due
to data type mismatch: argument 2 requires (timestamp or timestamp without time
zone) type, however, ''2011-11-11 11:11:10'' is of string type.; line 1 pos 7
-- !query
-select '2011-11-11 11:11:11' - interval '2' second
+select '2011-11-11 11:11:11' - timestamp'2011-11-11 11:11:10'
-- !query schema
-struct<2011-11-11 11:11:11 - INTERVAL '02' SECOND:string>
+struct<(2011-11-11 11:11:11 - TIMESTAMP '2011-11-11 11:11:10'):interval day to
second>
-- !query output
-2011-11-11 11:11:09
+0 00:00:01.000000000
-- !query
-select '1' - interval '2' second
+select timestamp'2011-11-11 11:11:11' - null
-- !query schema
-struct<>
+struct<(TIMESTAMP '2011-11-11 11:11:11' - NULL):interval day to second>
-- !query output
-java.time.DateTimeException
-Cannot cast 1 to TimestampType.
+NULL
-- !query
-select 1 - interval '2' second
+select null - timestamp'2011-11-11 11:11:11'
-- !query schema
-struct<>
+struct<(NULL - TIMESTAMP '2011-11-11 11:11:11'):interval day to second>
-- !query output
-org.apache.spark.sql.AnalysisException
-cannot resolve '1 + (- INTERVAL '02' SECOND)' due to data type mismatch:
argument 1 requires (timestamp or timestamp without time zone) type, however,
'1' is of int type.; line 1 pos 7
+NULL
-- !query
-select '2011-11-11 11:11:11' - timestamp'2011-11-11 11:11:10'
+create temporary view ts_view as select '2011-11-11 11:11:11' str
-- !query schema
-struct<(2011-11-11 11:11:11 - TIMESTAMP '2011-11-11 11:11:10'):interval day to
second>
+struct<>
-- !query output
-0 00:00:01.000000000
+
-- !query
-create temporary view v3 as select '2011-11-11 11:11:11' str
+select str - timestamp'2011-11-11 11:11:11' from ts_view
-- !query schema
struct<>
-- !query output
-
+org.apache.spark.sql.AnalysisException
+cannot resolve '(ts_view.str - TIMESTAMP '2011-11-11 11:11:11')' due to data
type mismatch: argument 1 requires (timestamp or timestamp without time zone)
type, however, 'ts_view.str' is of string type.; line 1 pos 7
-- !query
-select str - interval '2' second from v3
+select timestamp'2011-11-11 11:11:11' - str from ts_view
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
-cannot resolve 'v3.str + (- INTERVAL '02' SECOND)' due to data type mismatch:
argument 1 requires (timestamp or timestamp without time zone) type, however,
'v3.str' is of string type.; line 1 pos 7
+cannot resolve '(TIMESTAMP '2011-11-11 11:11:11' - ts_view.str)' due to data
type mismatch: argument 2 requires (timestamp or timestamp without time zone)
type, however, 'ts_view.str' is of string type.; line 1 pos 7
-- !query
-select str - date'2011-11-11' from v3
+select timestamp'2011-11-11 11:11:11' + '1'
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
-cannot resolve '(v3.str - DATE '2011-11-11')' due to data type mismatch:
argument 1 requires date type, however, 'v3.str' is of string type.; line 1 pos
7
+cannot resolve '(TIMESTAMP '2011-11-11 11:11:11' + CAST('1' AS TIMESTAMP))'
due to data type mismatch: '(TIMESTAMP '2011-11-11 11:11:11' + CAST('1' AS
TIMESTAMP))' requires (numeric or interval or interval day to second or
interval year to month) type, not timestamp; line 1 pos 7
-- !query
-select str - timestamp'2011-11-11 11:11:10' from v3
+select '1' + timestamp'2011-11-11 11:11:11'
-- !query schema
struct<>
-- !query output
org.apache.spark.sql.AnalysisException
-cannot resolve '(v3.str - TIMESTAMP '2011-11-11 11:11:10')' due to data type
mismatch: argument 1 requires (timestamp or timestamp without time zone) type,
however, 'v3.str' is of string type.; line 1 pos 7
+cannot resolve '(CAST('1' AS TIMESTAMP) + TIMESTAMP '2011-11-11 11:11:11')'
due to data type mismatch: '(CAST('1' AS TIMESTAMP) + TIMESTAMP '2011-11-11
11:11:11')' requires (numeric or interval or interval day to second or interval
year to month) type, not timestamp; line 1 pos 7
-- !query
-select date'2020-01-01' - timestamp'2019-10-06 10:11:12.345678'
+select timestamp'2011-11-11 11:11:11' + null
-- !query schema
-struct<(DATE '2020-01-01' - TIMESTAMP '2019-10-06 10:11:12.345678'):interval
day to second>
+struct<>
-- !query output
-86 13:48:47.654322000
+org.apache.spark.sql.AnalysisException
+cannot resolve '(TIMESTAMP '2011-11-11 11:11:11' + NULL)' due to data type
mismatch: differing types in '(TIMESTAMP '2011-11-11 11:11:11' + NULL)'
(timestamp and void).; line 1 pos 7
-- !query
-select timestamp'2019-10-06 10:11:12.345678' - date'2020-01-01'
+select null + timestamp'2011-11-11 11:11:11'
-- !query schema
-struct<(TIMESTAMP '2019-10-06 10:11:12.345678' - DATE '2020-01-01'):interval
day to second>
+struct<>
-- !query output
--86 13:48:47.654322000
+org.apache.spark.sql.AnalysisException
+cannot resolve '(NULL + TIMESTAMP '2011-11-11 11:11:11')' due to data type
mismatch: differing types in '(NULL + TIMESTAMP '2011-11-11 11:11:11')' (void
and timestamp).; line 1 pos 7
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]