[SPARK-42045][SQL] ANSI SQL mode: Round/Bround should return an error on integer overflow#39546
Closed
gengliangwang wants to merge 5 commits intoapache:masterfrom
Closed
[SPARK-42045][SQL] ANSI SQL mode: Round/Bround should return an error on integer overflow#39546gengliangwang wants to merge 5 commits intoapache:masterfrom
gengliangwang wants to merge 5 commits intoapache:masterfrom
Conversation
cloud-fan
reviewed
Jan 13, 2023
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/mathExpressions.scala
Show resolved
Hide resolved
cloud-fan
approved these changes
Jan 13, 2023
Member
Author
|
Merging to master |
gengliangwang
added a commit
that referenced
this pull request
Jan 14, 2023
… on tiny/small/big integer overflow ### What changes were proposed in this pull request? Similar to #39546, this PR is to change Round/Bround to return an error on tiny/small/big integer overflow. ### Why are the changes needed? In ANSI SQL mode, integer overflow should cause error instead of returning an unreasonable result. For example, round(127y, -1) should return error instead of returning -126 ### Does this PR introduce _any_ user-facing change? Yes, in ANSI SQL mode, SQL function Round and Bround will return an error on tiny/small/big integer overflow ### How was this patch tested? UTs Closes #39557 from gengliangwang/fixRoundOtherInt. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Gengliang Wang <gengliang@apache.org>
This file contains hidden or 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
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 ANSI SQL mode, Round/Bround should return an error on integer overflow.
Note this PR is for integer only. Once it is merge, I will create one follow-up PR for all the rest integral types: byte, short, and long.
Also, the function ceil and floor accepts decimal type input, so there is no need to change them.
Why are the changes needed?
In ANSI SQL mode, integer overflow should cause error instead of returning an unreasonable result.
For example,
round(2147483647, -1)should return error instead of returning-2147483646Does this PR introduce any user-facing change?
Yes, in ANSI SQL mode, SQL function Round and Bround will return an error on integer overflow
How was this patch tested?
UT