-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-22894][SQL] DateTimeOperations should accept SQL like string type #20067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -20,7 +20,7 @@ package org.apache.spark.sql | |||
| import java.io.File | ||||
| import java.math.MathContext | ||||
| import java.net.{MalformedURLException, URL} | ||||
| import java.sql.Timestamp | ||||
| import java.sql.{Date, Timestamp} | ||||
| import java.util.concurrent.atomic.AtomicBoolean | ||||
|
|
||||
| import org.apache.spark.{AccumulatorSuite, SparkException} | ||||
|
|
@@ -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") | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So far, we issue an exception. What is the behavior of Hive?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hive doesn't accept string type:
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But Spark was originally supported: spark/sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/analysis/TypeCoercionSuite.scala Line 1083 in bc0848b
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I saw the original PR https://github.com/apache/spark/pull/7754/files#r35821191 Maybe the SQL API should support it since we do support it in DataFrame APIs. |
||||
| val dt = sql(s"SELECT CAST('$date' as DATE) + interval 2 months 2 seconds") | ||||
| val ts = sql(s"SELECT CAST('$date' as TIMESTAMP) + interval 2 months 2 seconds") | ||||
|
|
||||
| checkAnswer(str, Row("2018-02-24 00:00:02") :: Nil) | ||||
| checkAnswer(dt, Row(Date.valueOf("2018-02-24")) :: Nil) | ||||
| checkAnswer(ts, Row(Timestamp.valueOf("2018-02-24 00:00:02")) :: Nil) | ||||
| } | ||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please get rid of this test case and merge them to #20061 |
||||
|
|
||||
| // Only New OrcFileFormat supports this | ||||
| Seq(classOf[org.apache.spark.sql.execution.datasources.orc.OrcFileFormat].getCanonicalName, | ||||
| "parquet").foreach { format => | ||||
|
|
||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add it to #20061?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll and it.