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-34737][SQL] Cast input float to double in TIMESTAMP_SECONDS #31831

Closed
wants to merge 1 commit into from

Conversation

MaxGekk
Copy link
Member

@MaxGekk MaxGekk commented Mar 14, 2021

What changes were proposed in this pull request?

In the PR, I propose to cast the input float to double in the SecondsToTimestamp expression in the same way as in the Cast expression.

Why are the changes needed?

To have the same results from CAST(<float> AS TIMESTAMP) and from TIMESTAMP_SECONDS:

spark-sql> SELECT CAST(16777215.0f AS TIMESTAMP);
1970-07-14 07:20:15
spark-sql> SELECT TIMESTAMP_SECONDS(16777215.0f);
1970-07-14 07:20:14.951424

Does this PR introduce any user-facing change?

Yes. After the changes:

spark-sql> SELECT TIMESTAMP_SECONDS(16777215.0f);
1970-07-14 07:20:15

How was this patch tested?

By running new test:

$ build/sbt "test:testOnly *DateExpressionsSuite"

@github-actions github-actions bot added the SQL label Mar 14, 2021
@SparkQA
Copy link

SparkQA commented Mar 14, 2021

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

@SparkQA
Copy link

SparkQA commented Mar 14, 2021

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

@MaxGekk
Copy link
Member Author

MaxGekk commented Mar 14, 2021

@HyukjinKwon @cloud-fan @yaooqinn @gengliangwang Could you review this PR, please.

@yaooqinn
Copy link
Member

LGTM~

@HyukjinKwon
Copy link
Member

Merged to master.

@MaxGekk
Copy link
Member Author

MaxGekk commented Mar 17, 2021

I would like to backport this to branch-3.1 if you don't mind.

MaxGekk added a commit to MaxGekk/spark that referenced this pull request Mar 17, 2021
In the PR, I propose to cast the input float to double in the `SecondsToTimestamp` expression in the same way as in the `Cast` expression.

To have the same results from `CAST(<float> AS TIMESTAMP)` and from `TIMESTAMP_SECONDS`:
```sql
spark-sql> SELECT CAST(16777215.0f AS TIMESTAMP);
1970-07-14 07:20:15
spark-sql> SELECT TIMESTAMP_SECONDS(16777215.0f);
1970-07-14 07:20:14.951424
```

Yes. After the changes:
```sql
spark-sql> SELECT TIMESTAMP_SECONDS(16777215.0f);
1970-07-14 07:20:15
```

By running new test:
```
$ build/sbt "test:testOnly *DateExpressionsSuite"
```

Closes apache#31831 from MaxGekk/adjust-SecondsToTimestamp.

Authored-by: Max Gekk <[email protected]>
Signed-off-by: HyukjinKwon <[email protected]>
(cherry picked from commit 7aaed76)
Signed-off-by: Max Gekk <[email protected]>
@MaxGekk
Copy link
Member Author

MaxGekk commented Mar 17, 2021

Here is the backport to 3.1: #31872

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

Successfully merging this pull request may close these issues.

4 participants