-
- Downloads
[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.
Showing
- sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/datetimeExpressions.scala 2 additions, 0 deletions.../spark/sql/catalyst/expressions/datetimeExpressions.scala
- sql/hive/src/test/resources/sqlgen/interval_arithmetic.sql 8 additions, 0 deletionssql/hive/src/test/resources/sqlgen/interval_arithmetic.sql
- sql/hive/src/test/scala/org/apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala 17 additions, 1 deletion...apache/spark/sql/catalyst/ExpressionSQLBuilderSuite.scala
- sql/hive/src/test/scala/org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala 16 additions, 0 deletions...org/apache/spark/sql/catalyst/LogicalPlanToSQLSuite.scala
Loading
Please register or sign in to comment