Skip to content
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

Closed
wants to merge 3 commits into from

Conversation

gengliangwang
Copy link
Member

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

@@ -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)
Copy link
Member Author

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);"
Copy link
Contributor

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.

@github-actions github-actions bot added the SQL label Jun 10, 2021
@SparkQA
Copy link

SparkQA commented Jun 10, 2021

Kubernetes integration test starting
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/44181/

@SparkQA
Copy link

SparkQA commented Jun 10, 2021

Kubernetes integration test status success
URL: https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder-K8s/44181/

@MaxGekk
Copy link
Member

MaxGekk commented Jun 10, 2021

+1, LGTM. Merging to master.
Thank you @gengliangwang, and @cloud-fan for your review.

@MaxGekk MaxGekk closed this in d21ff13 Jun 10, 2021
@SparkQA
Copy link

SparkQA commented Jun 10, 2021

Test build #139653 has finished for PR 32869 at commit dde4cd8.

  • This patch passes all tests.
  • This patch merges cleanly.
  • This patch adds no public classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants