Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
add negative value test
  • Loading branch information
yaooqinn committed Nov 19, 2019
commit 5b4f5186899556b66f4037c43c4c9aed0fd4ae6c
2 changes: 2 additions & 0 deletions sql/core/src/test/resources/sql-tests/inputs/interval.sql
Original file line number Diff line number Diff line change
Expand Up @@ -268,3 +268,5 @@ select interval '0.1 seconds';
select interval '0.49 microseconds';
select interval '0.50 microseconds';
select interval '87649415 hours 59 minutes 59 seconds 999 milliseconds 999 microseconds';
select interval '-0.51 year';
select interval '-0.41 year';
88 changes: 52 additions & 36 deletions sql/core/src/test/resources/sql-tests/results/ansi/interval.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 140
-- Number of queries: 142


-- !query 0
Expand Down Expand Up @@ -1196,34 +1196,50 @@ struct<INTERVAL '87649415 hours 59 minutes 59.999999 seconds':interval>


-- !query 128
select 1 year 2 days
select interval '-0.51 year'
-- !query 128 schema
struct<INTERVAL '1 years 2 days':interval>
struct<INTERVAL '-6 months':interval>
-- !query 128 output
1 years 2 days
-6 months


-- !query 129
select '10-9' year to month
select interval '-0.41 year'
-- !query 129 schema
struct<INTERVAL '10 years 9 months':interval>
struct<INTERVAL '-4 months':interval>
-- !query 129 output
10 years 9 months
-4 months


-- !query 130
select '20 15:40:32.99899999' day to second
select 1 year 2 days
-- !query 130 schema
struct<INTERVAL '20 days 15 hours 40 minutes 32.998999 seconds':interval>
struct<INTERVAL '1 years 2 days':interval>
-- !query 130 output
20 days 15 hours 40 minutes 32.998999 seconds
1 years 2 days


-- !query 131
select 30 day day
select '10-9' year to month
-- !query 131 schema
struct<>
struct<INTERVAL '10 years 9 months':interval>
-- !query 131 output
10 years 9 months


-- !query 132
select '20 15:40:32.99899999' day to second
-- !query 132 schema
struct<INTERVAL '20 days 15 hours 40 minutes 32.998999 seconds':interval>
-- !query 132 output
20 days 15 hours 40 minutes 32.998999 seconds


-- !query 133
select 30 day day
-- !query 133 schema
struct<>
-- !query 133 output
org.apache.spark.sql.catalyst.parser.ParseException

no viable alternative at input 'day'(line 1, pos 14)
Expand All @@ -1233,27 +1249,27 @@ select 30 day day
--------------^^^


-- !query 132
-- !query 134
select date'2012-01-01' - '2-2' year to month
-- !query 132 schema
-- !query 134 schema
struct<CAST(CAST(DATE '2012-01-01' AS TIMESTAMP) - INTERVAL '2 years 2 months' AS DATE):date>
-- !query 132 output
-- !query 134 output
2009-11-01


-- !query 133
-- !query 135
select 1 month - 1 day
-- !query 133 schema
-- !query 135 schema
struct<INTERVAL '1 months -1 days':interval>
-- !query 133 output
-- !query 135 output
1 months -1 days


-- !query 134
-- !query 136
select 1 year to month
-- !query 134 schema
-- !query 136 schema
struct<>
-- !query 134 output
-- !query 136 output
org.apache.spark.sql.catalyst.parser.ParseException

The value of from-to unit must be a string(line 1, pos 7)
Expand All @@ -1263,11 +1279,11 @@ select 1 year to month
-------^^^


-- !query 135
-- !query 137
select '1' year to second
-- !query 135 schema
-- !query 137 schema
struct<>
-- !query 135 output
-- !query 137 output
org.apache.spark.sql.catalyst.parser.ParseException

Intervals FROM year TO second are not supported.(line 1, pos 7)
Expand All @@ -1277,11 +1293,11 @@ select '1' year to second
-------^^^


-- !query 136
-- !query 138
select 1 year '2-1' year to month
-- !query 136 schema
-- !query 138 schema
struct<>
-- !query 136 output
-- !query 138 output
org.apache.spark.sql.catalyst.parser.ParseException

Can only have a single from-to unit in the interval literal syntax(line 1, pos 14)
Expand All @@ -1291,11 +1307,11 @@ select 1 year '2-1' year to month
--------------^^^


-- !query 137
-- !query 139
select (-30) day
-- !query 137 schema
-- !query 139 schema
struct<>
-- !query 137 output
-- !query 139 output
org.apache.spark.sql.catalyst.parser.ParseException

no viable alternative at input 'day'(line 1, pos 13)
Expand All @@ -1305,11 +1321,11 @@ select (-30) day
-------------^^^


-- !query 138
-- !query 140
select (a + 1) day
-- !query 138 schema
-- !query 140 schema
struct<>
-- !query 138 output
-- !query 140 output
org.apache.spark.sql.catalyst.parser.ParseException

no viable alternative at input 'day'(line 1, pos 15)
Expand All @@ -1319,11 +1335,11 @@ select (a + 1) day
---------------^^^


-- !query 139
-- !query 141
select 30 day day day
-- !query 139 schema
-- !query 141 schema
struct<>
-- !query 139 output
-- !query 141 output
org.apache.spark.sql.catalyst.parser.ParseException

no viable alternative at input 'day'(line 1, pos 14)
Expand Down
18 changes: 17 additions & 1 deletion sql/core/src/test/resources/sql-tests/results/interval.sql.out
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
-- Automatically generated by SQLQueryTestSuite
-- Number of queries: 128
-- Number of queries: 130


-- !query 0
Expand Down Expand Up @@ -1177,3 +1177,19 @@ select interval '87649415 hours 59 minutes 59 seconds 999 milliseconds 999 micro
struct<INTERVAL '87649415 hours 59 minutes 59.999999 seconds':interval>
-- !query 127 output
87649415 hours 59 minutes 59.999999 seconds


-- !query 128
select interval '-0.51 year'
-- !query 128 schema
struct<INTERVAL '-6 months':interval>
-- !query 128 output
-6 months


-- !query 129
select interval '-0.41 year'
-- !query 129 schema
struct<INTERVAL '-4 months':interval>
-- !query 129 output
-4 months