Uh oh!
There was an error while loading. Please reload this page.
[SPARK-36567][SQL] Support foldable special datetime strings by CAST - #33816
[SPARK-36567][SQL] Support foldable special datetime strings by CAST#33816MaxGekk wants to merge 4 commits into
CAST#33816Conversation
SparkQA
commented
Aug 23, 2021
Test build #142708 has finished for PR 33816 at commit
|
SparkQA
commented
Aug 23, 2021
Kubernetes integration test starting |
SparkQA
commented
Aug 23, 2021
Kubernetes integration test status success |
SparkQA
commented
Aug 23, 2021
Kubernetes integration test starting |
SparkQA
commented
Aug 23, 2021
Kubernetes integration test status failure |
SparkQA
commented
Aug 24, 2021
Test build #142709 has finished for PR 33816 at commit
|
Uh oh!
There was an error while loading. Please reload this page.
SparkQA
commented
Aug 24, 2021
Kubernetes integration test starting |
CASTCASTSparkQA
commented
Aug 24, 2021
Kubernetes integration test status failure |
MaxGekk
commented
Aug 24, 2021
@cloud-fan@gengliangwang@HyukjinKwon Could you review this PR, please. |
SparkQA
commented
Aug 24, 2021
Test build #142741 has finished for PR 33816 at commit
|
cloud-fan
commented
Aug 25, 2021
thanks, merging to master/3.2! |
### What changes were proposed in this pull request? In the PR, I propose to add new correctness rule `SpecialDatetimeValues` to the final analysis phase. It replaces casts of strings to date/timestamp_ltz/timestamp_ntz by literals of such types if the strings contain special datetime values like `today`, `yesterday` and `tomorrow`, and the input strings are foldable. ### Why are the changes needed? 1. To avoid a breaking change. 2. To improve user experience with Spark SQL. After the PR #32714, users have to use typed literals instead of implicit casts. For instance, at Spark 3.1: ```sql select ts_col > 'now'; ``` but the query fails at the moment, and users have to use typed timestamp literal: ```sql select ts_col > timestamp'now'; ``` ### Does this PR introduce _any_ user-facing change? No. Previous release 3.1 has supported the feature already till it was removed by #32714. ### How was this patch tested? 1. Manually tested via the sql command line: ```sql spark-sql> select cast('today' as date); 2021-08-24 spark-sql> select timestamp('today'); 2021-08-24 00:00:00 spark-sql> select timestamp'tomorrow' > 'today'; true ``` 2. By running new test suite: ``` $ build/sbt "sql/testOnly org.apache.spark.sql.catalyst.optimizer.SpecialDatetimeValuesSuite" ``` Closes#33816 from MaxGekk/foldable-datetime-special-values. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit df0ec56) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
cloud-fan
commented
Aug 25, 2021
@MaxGekk I think we should also update the migration guide? |
MaxGekk
commented
Aug 25, 2021
Here is the update for the SQL migration guide #33840 |
…ion guide about foldable special datetime values ### What changes were proposed in this pull request? In the PR, I propose to update an existing item in the SQL migration guide, and mention that Spark 3.2 supports foldable special datetime values as well. <img width="1292" alt="Screenshot 2021-08-25 at 23 29 51" src="https://user-images.githubusercontent.com/1580697/130860184-27f0ba56-6c2d-4a5a-91a8-195f2f8aa5da.png"> ### Why are the changes needed? To inform users about actual Spark SQL behavior introduced by #33816 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? By generating docs, and checking results manually. Closes#33840 from MaxGekk/special-datetime-cast-migr-guide. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
…ion guide about foldable special datetime values ### What changes were proposed in this pull request? In the PR, I propose to update an existing item in the SQL migration guide, and mention that Spark 3.2 supports foldable special datetime values as well. <img width="1292" alt="Screenshot 2021-08-25 at 23 29 51" src="https://user-images.githubusercontent.com/1580697/130860184-27f0ba56-6c2d-4a5a-91a8-195f2f8aa5da.png"> ### Why are the changes needed? To inform users about actual Spark SQL behavior introduced by #33816 ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? By generating docs, and checking results manually. Closes#33840 from MaxGekk/special-datetime-cast-migr-guide. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com> (cherry picked from commit c4e739f) Signed-off-by: Wenchen Fan <wenchen@databricks.com>
What changes were proposed in this pull request?
In the PR, I propose to add new correctness rule
SpecialDatetimeValuesto the final analysis phase. It replaces casts of strings to date/timestamp_ltz/timestamp_ntz by literals of such types if the strings contain special datetime values liketoday,yesterdayandtomorrow, and the input strings are foldable.Why are the changes needed?
at Spark 3.1:
but the query fails at the moment, and users have to use typed timestamp literal:
Does this PR introduce any user-facing change?
No. Previous release 3.1 has supported the feature already till it was removed by #32714.
How was this patch tested?