You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2021/03/12 13:18:44 UTC

[GitHub] [spark] MaxGekk opened a new pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

MaxGekk opened a new pull request #31819:
URL: https://github.com/apache/spark/pull/31819


   ### What changes were proposed in this pull request?
   In non-ANSI mode, casting float to timestamp has different implementation for codegen on and off.
   
   Codegen on:
   1. Multiply float input by MICROS_PER_SECOND
   2. Cast resulting float value to long
   
   Codegen off:
   1. CAST float input to double input
   2. Multiply double input by MICROS_PER_SECOND
   3. Cast resulting double value to long
   
   In the PR, I propose to align non-codegen code, and cast input float to double.
   
   ### Why are the changes needed?
   This fixes the issue which is demonstrated by the code:
   ```sql
   spark-sql> CREATE TEMP VIEW v1 AS SELECT 16777215.0f AS f;
   spark-sql> SELECT * FROM v1;
   1.6777215E7
   spark-sql> SELECT CAST(f AS TIMESTAMP) FROM v1;
   1970-07-14 07:20:15
   spark-sql> CACHE TABLE v1;
   spark-sql> SELECT * FROM v1;
   1.6777215E7
   spark-sql> SELECT CAST(f AS TIMESTAMP) FROM v1;
   1970-07-14 07:20:14.951424
   ```
   The result from the cached view **1970-07-14 07:20:14.951424** is different from un-cached view **1970-07-14 07:20:15**.
   
   ### Does this PR introduce _any_ user-facing change?
   Yes. After the changes, the example above outputs the same timestamp for the cached view:
   ```sql
   spark-sql> CACHE TABLE v1;
   spark-sql> SELECT * FROM v1;
   1.6777215E7
   spark-sql> SELECT CAST(f AS TIMESTAMP) FROM v1;
   1970-07-14 07:20:15
   ```
   
   ### How was this patch tested?
   By running new test:
   ```
   $ build/sbt "test:testOnly *CastSuite"
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #31819:
URL: https://github.com/apache/spark/pull/31819#issuecomment-797497681


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder-K8s/40588/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #31819:
URL: https://github.com/apache/spark/pull/31819#issuecomment-799961312


   I also merged this to branch-3.1 too


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] AmplabJenkins commented on pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #31819:
URL: https://github.com/apache/spark/pull/31819#issuecomment-797523004


   
   Refer to this link for build results (access rights to CI server needed): 
   https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/136004/
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon closed pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

Posted by GitBox <gi...@apache.org>.
HyukjinKwon closed pull request #31819:
URL: https://github.com/apache/spark/pull/31819


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] [spark] HyukjinKwon commented on pull request #31819: [SPARK-34727][SQL] Fix discrepancy in casting float to timestamp

Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #31819:
URL: https://github.com/apache/spark/pull/31819#issuecomment-798821791


   Merged to master.


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org