[SPARK-42427][SQL] ANSI MODE: Conv should return an error if the internal conversion overflows#40001
Closed
gengliangwang wants to merge 1 commit intoapache:masterfrom
Closed
[SPARK-42427][SQL] ANSI MODE: Conv should return an error if the internal conversion overflows#40001gengliangwang wants to merge 1 commit intoapache:masterfrom
gengliangwang wants to merge 1 commit intoapache:masterfrom
Conversation
cloud-fan
approved these changes
Feb 15, 2023
Member
Author
|
Merging to master/3.4 |
gengliangwang
added a commit
that referenced
this pull request
Feb 15, 2023
…rnal conversion overflows
### What changes were proposed in this pull request?
In ANSI SQL mode, function Conv() should return an error if the internal conversion overflows
For example, before the change:
```
> select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
18446744073709551615
```
After the change
```
> select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
org.apache.spark.SparkArithmeticException: [ARITHMETIC_OVERFLOW] Overflow in function conv(). If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.
== SQL(line 1, position 8) ==
select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
### Why are the changes needed?
Similar to the other SQL functions, this PR shows the overflow errors of `conv()` to users under ANSI SQL mode, instead of returning an unexpected number.
### Does this PR introduce _any_ user-facing change?
Yes, function `conv()` will return an error if the internal conversion overflows
### How was this patch tested?
UTs
Closes #40001 from gengliangwang/fixConv.
Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
(cherry picked from commit cb463fb)
Signed-off-by: Gengliang Wang <gengliang@apache.org>
snmvaughan
pushed a commit
to snmvaughan/spark
that referenced
this pull request
Jun 20, 2023
…rnal conversion overflows
### What changes were proposed in this pull request?
In ANSI SQL mode, function Conv() should return an error if the internal conversion overflows
For example, before the change:
```
> select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
18446744073709551615
```
After the change
```
> select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
org.apache.spark.SparkArithmeticException: [ARITHMETIC_OVERFLOW] Overflow in function conv(). If necessary set "spark.sql.ansi.enabled" to "false" to bypass this error.
== SQL(line 1, position 8) ==
select conv('fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff', 16, 10)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
### Why are the changes needed?
Similar to the other SQL functions, this PR shows the overflow errors of `conv()` to users under ANSI SQL mode, instead of returning an unexpected number.
### Does this PR introduce _any_ user-facing change?
Yes, function `conv()` will return an error if the internal conversion overflows
### How was this patch tested?
UTs
Closes apache#40001 from gengliangwang/fixConv.
Authored-by: Gengliang Wang <gengliang@apache.org>
Signed-off-by: Gengliang Wang <gengliang@apache.org>
(cherry picked from commit cb463fb)
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, function Conv() should return an error if the internal conversion overflows
For example, before the change:
After the change
Why are the changes needed?
Similar to the other SQL functions, this PR shows the overflow errors of
conv()to users under ANSI SQL mode, instead of returning an unexpected number.Does this PR introduce any user-facing change?
Yes, function
conv()will return an error if the internal conversion overflowsHow was this patch tested?
UTs