Github user wangyum commented on a diff in the pull request:
https://github.com/apache/spark/pull/20067#discussion_r158647982
--- Diff: sql/core/src/test/scala/org/apache/spark/sql/SQLQuerySuite.scala
---
@@ -2760,6 +2760,17 @@ class SQLQuerySuite extends QueryTest with
SharedSQLContext {
}
}
+ test("SPARK-22894: DateTimeOperations should accept SQL like string
type") {
+ val date = "2017-12-24"
+ val str = sql(s"SELECT CAST('$date' as STRING) + interval 2 months 2
seconds")
--- End diff --
Hive doesn't accept string type:
```
hive> SELECT cast('2017-12-24' as date) + interval 2 day;
2017-12-26 00:00:00
hive> SELECT cast('2017-12-24' as timestamp) + interval 2 day;
2017-12-26 00:00:00
hive> SELECT cast('2017-12-24' as string) + interval 2 day;
FAILED: SemanticException Line 0:-1 Wrong arguments '2': No matching method
for class org.apache.hadoop.hive.ql.udf.generic.GenericUDFOPDTIPlus with
(string, interval_day_time)
hive>
```
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]