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
[SPARK-35716][SQL] Support casting of timestamp without time zone to date type #32869
Conversation
@@ -1256,10 +1256,17 @@ abstract class AnsiCastSuiteBase extends CastSuiteBase { | |||
|
|||
test("SPARK-35711: cast timestamp without time zone to timestamp with local time zone") { | |||
specialTs.foreach { s => | |||
val dt = LocalDateTime.parse(s.replace(" ", "T")) | |||
val dt = LocalDateTime.parse(s) |
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.
This is a trivial change for the test case. There is no need to replace the space.
case TimestampWithoutTZType => | ||
(c, evPrim, evNull) => | ||
// scalastyle:off line.size.limit | ||
code"$evPrim = org.apache.spark.sql.catalyst.util.DateTimeUtils.microsToDays($c, java.time.ZoneOffset.UTC);" |
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.
nit: we can add a protected def dtUtilCls = classOf[DateTimeUtils].getClass.getName
in CaseBase
, to shorten the code here and other places.
Kubernetes integration test starting |
Kubernetes integration test status success |
+1, LGTM. Merging to master. |
Test build #139653 has finished for PR 32869 at commit
|
What changes were proposed in this pull request?
Extend the Cast expression and support TimestampWithoutTZType in casting to DateType.
Why are the changes needed?
To conform the ANSI SQL standard which requires to support such casting.
Does this PR introduce any user-facing change?
No, the new timestamp type is not released yet.
How was this patch tested?
Unit test