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-40008][SQL] Support casting of integrals to ANSI intervals #37442
Closed
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MaxGekk
changed the title
[SPARK-40008][SQL] Support casting integrals to intervals in ANSI mode
[SPARK-40008][SQL] Support casting of integrals to ANSI intervals
Aug 8, 2022
HyukjinKwon
approved these changes
Aug 9, 2022
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.
LGTM, cc @gengliangwang
cloud-fan
approved these changes
Aug 9, 2022
Merging to master. Thank you, @HyukjinKwon @cloud-fan for review. |
MaxGekk
added a commit
that referenced
this pull request
Aug 10, 2022
… intervals ### What changes were proposed in this pull request? This is a follow up of #37442 that fixes the codegen of casting integrals to ANSI intervals w/ multi units. The PR removes the assert: ```scala assert(it.startField == it.endField) ``` ### Why are the changes needed? To make codegen consistent to interpreted code, and fix the assert. ### Does this PR introduce _any_ user-facing change? Yes. Before: ```sql > select cast(dt as interval hour to second) from values(100Y) as t(dt); java.lang.AssertionError assertion failed ``` After: ```sql > select cast(dt as interval hour to second) from values(100Y) as t(dt); 0 00:01:40.000000000 ``` ### How was this patch tested? By running new tests: ``` $ build/sbt "sql/testOnly org.apache.spark.sql.SQLQueryTestSuite -- -z cast.sql" ``` Closes #37464 from MaxGekk/cast-integral-to-interval-followup. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
MaxGekk
added a commit
that referenced
this pull request
Aug 13, 2022
### What changes were proposed in this pull request? In the PR, I propose to update the doc page https://spark.apache.org/docs/latest/sql-ref-ansi-compliance.html#cast about new behaviour of CAST introduced by the following PRs: 1. [[SPARK-40008][SQL] Support casting of integrals to ANSI intervals](#37442) 2. [[SPARK-39451][SQL] Support casting intervals to integrals in ANSI mode](#36811) 3. [[SPARK-39470][SQL] Support cast of ANSI intervals to decimals](#36857) 4. [[SPARK-40014][SQL] Support cast of decimals to ANSI intervals](#37466) <img width="1004" alt="Screenshot 2022-08-12 at 15 00 10" src="https://user-images.githubusercontent.com/1580697/184349887-700c64f6-e9c8-40c4-85cc-a77072506cf5.png"> ### Why are the changes needed? To inform Spark SQL about new behaviour of `CAST`. ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? By building Spark SQL docs and check them manually: ``` $ SKIP_SCALADOC=1 SKIP_PYTHONDOC=1 SKIP_RDOC=1 bundle exec jekyll build ``` Closes #37495 from MaxGekk/doc-interval-cast. Authored-by: Max Gekk <max.gekk@gmail.com> Signed-off-by: Max Gekk <max.gekk@gmail.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
In the PR, I propose
TINYINT
,SMALLINT
,INT
,BIGINT
to ANSI interval types.This PR is complement to #36811.
Why are the changes needed?
To conform the SQL standard which allows such casting:
Does this PR introduce any user-facing change?
No, it extends existing behavior.
How was this patch tested?
By running new tests: