Skip to content

[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
gengliangwang:fixRound
Closed

[SPARK-42045][SQL] ANSI SQL mode: Round/Bround should return an error on integer overflow#39546
gengliangwang wants to merge 5 commits intoapache:masterfrom
gengliangwang:fixRound

Conversation

@gengliangwang
Copy link
Member

@gengliangwang gengliangwang commented Jan 13, 2023

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 -2147483646

Does 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

@gengliangwang
Copy link
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>
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.

2 participants