aboutsummaryrefslogtreecommitdiff
path: root/sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql
diff options
context:
space:
mode:
authorDongjoon Hyun <dongjoon@apache.org>2016-10-06 09:42:30 -0700
committergatorsmile <gatorsmile@gmail.com>2016-10-06 09:42:30 -0700
commit92b7e5728025b1bb6ed3aab5f1753c946a73568c (patch)
tree7620ed80d9295210f5ce36eaa25b0a2ebb8a65f0 /sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql
parent5e9f32dd87e58e909a579eaa310e67d31c3b6573 (diff)
downloadspark-92b7e5728025b1bb6ed3aab5f1753c946a73568c.tar.gz
spark-92b7e5728025b1bb6ed3aab5f1753c946a73568c.tar.bz2
spark-92b7e5728025b1bb6ed3aab5f1753c946a73568c.zip
[SPARK-17750][SQL] Fix CREATE VIEW with INTERVAL arithmetic.
## What changes were proposed in this pull request? Currently, Spark raises `RuntimeException` when creating a view with timestamp with INTERVAL arithmetic like the following. The root cause is the arithmetic expression, `TimeAdd`, was transformed into `timeadd` function as a VIEW definition. This PR fixes the SQL definition of `TimeAdd` and `TimeSub` expressions. ```scala scala> sql("CREATE TABLE dates (ts TIMESTAMP)") scala> sql("CREATE VIEW view1 AS SELECT ts + INTERVAL 1 DAY FROM dates") java.lang.RuntimeException: Failed to analyze the canonicalized SQL: ... ``` ## How was this patch tested? Pass Jenkins with a new testcase. Author: Dongjoon Hyun <dongjoon@apache.org> Closes #15318 from dongjoon-hyun/SPARK-17750.
Diffstat (limited to 'sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql')
-rw-r--r--sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql8
1 files changed, 8 insertions, 0 deletions
diff --git a/sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql b/sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql
new file mode 100644
index 0000000000..31d0034876
--- /dev/null
+++ b/sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql
@@ -0,0 +1,8 @@
+-- This file is automatically generated by LogicalPlanToSQLSuite.
+select ts + interval 1 day, ts + interval 2 days,
+ ts - interval 1 day, ts - interval 2 days,
+ ts + interval '1' day, ts + interval '2' days,
+ ts - interval '1' day, ts - interval '2' days
+from dates
+--------------------------------------------------------------------------------
+SELECT `gen_attr_0` AS `CAST(ts + interval 1 days AS TIMESTAMP)`, `gen_attr_2` AS `CAST(ts + interval 2 days AS TIMESTAMP)`, `gen_attr_3` AS `CAST(ts - interval 1 days AS TIMESTAMP)`, `gen_attr_4` AS `CAST(ts - interval 2 days AS TIMESTAMP)`, `gen_attr_5` AS `CAST(ts + interval 1 days AS TIMESTAMP)`, `gen_attr_6` AS `CAST(ts + interval 2 days AS TIMESTAMP)`, `gen_attr_7` AS `CAST(ts - interval 1 days AS TIMESTAMP)`, `gen_attr_8` AS `CAST(ts - interval 2 days AS TIMESTAMP)` FROM (SELECT CAST(`gen_attr_1` + interval 1 days AS TIMESTAMP) AS `gen_attr_0`, CAST(`gen_attr_1` + interval 2 days AS TIMESTAMP) AS `gen_attr_2`, CAST(`gen_attr_1` - interval 1 days AS TIMESTAMP) AS `gen_attr_3`, CAST(`gen_attr_1` - interval 2 days AS TIMESTAMP) AS `gen_attr_4`, CAST(`gen_attr_1` + interval 1 days AS TIMESTAMP) AS `gen_attr_5`, CAST(`gen_attr_1` + interval 2 days AS TIMESTAMP) AS `gen_attr_6`, CAST(`gen_attr_1` - interval 1 days AS TIMESTAMP) AS `gen_attr_7`, CAST(`gen_attr_1` - interval 2 days AS TIMESTAMP) AS `gen_attr_8` FROM (SELECT `ts` AS `gen_attr_1` FROM `default`.`dates`) AS gen_subquery_0) AS gen_subquery_1