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-39889][SQL] Use different error classes for numeric/interval divided by 0 #37313
Conversation
cc @entong as well |
@@ -210,6 +210,12 @@ | |||
"<message>" | |||
] | |||
}, | |||
"INTERVAL_DIVIDED_BY_ZERO" : { | |||
"message" : [ | |||
"Division by zero." |
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.
Doesn't try_divide
help here? The TryDivide
expression has some examples with intervals:
spark/sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/TryEval.scala
Lines 187 to 190 in 46175d1
> SELECT _FUNC_(interval 2 month, 2); | |
0-1 | |
> SELECT _FUNC_(interval 2 month, 0); | |
NULL |
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.
Make sense. I have updated the message. Thanks!
+1, LGTM. Merging to master (try to 3.3). |
@gengliangwang It conflicts w/ 3.3. It is up to you to backport it to branch-3.3. |
…rithmetic overflow ### What changes were proposed in this pull request? Similar with #37313, currently, when arithmetic overflow errors happen under ANSI mode, the error messages are like ``` [ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" ``` The "(except for ANSI interval type)" part is confusing. We should remove it for the numeric arithmetic operations and have a new error class for the interval division error: `INTERVAL_ARITHMETIC_OVERFLOW` ### Why are the changes needed? For better error messages ### Does this PR introduce _any_ user-facing change? Yes, Use different error classes for arithmetic overflows of numeric/interval.. After changes, the error messages are simpler and more clear. ### How was this patch tested? UT Closes #37337 from gengliangwang/improveOverflowMsg. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Gengliang Wang <gengliang@apache.org>
@MaxGekk Thanks, I will keep it on master branch for now. |
…rithmetic overflow ### What changes were proposed in this pull request? Similar with apache#37313, currently, when arithmetic overflow errors happen under ANSI mode, the error messages are like ``` [ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" ``` The "(except for ANSI interval type)" part is confusing. We should remove it for the numeric arithmetic operations and have a new error class for the interval division error: `INTERVAL_ARITHMETIC_OVERFLOW` ### Why are the changes needed? For better error messages ### Does this PR introduce _any_ user-facing change? Yes, Use different error classes for arithmetic overflows of numeric/interval.. After changes, the error messages are simpler and more clear. ### How was this patch tested? UT Closes apache#37337 from gengliangwang/improveOverflowMsg. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Gengliang Wang <gengliang@apache.org>
…rithmetic overflow ### What changes were proposed in this pull request? Similar with #37313, currently, when arithmetic overflow errors happen under ANSI mode, the error messages are like ``` [ARITHMETIC_OVERFLOW] long overflow. Use 'try_multiply' to tolerate overflow and return NULL instead. If necessary set spark.sql.ansi.enabled to "false" ``` The "(except for ANSI interval type)" part is confusing. We should remove it for the numeric arithmetic operations and have a new error class for the interval division error: `INTERVAL_ARITHMETIC_OVERFLOW` ### Why are the changes needed? For better error messages ### Does this PR introduce _any_ user-facing change? Yes, Use different error classes for arithmetic overflows of numeric/interval.. After changes, the error messages are simpler and more clear. ### How was this patch tested? UT Closes #37374 from gengliangwang/SPARK-39917. Authored-by: Gengliang Wang <gengliang@apache.org> Signed-off-by: Gengliang Wang <gengliang@apache.org>
What changes were proposed in this pull request?
Currently, when numbers are divided by 0 under ANSI mode, the error message is like
The "(except for ANSI interval type)" part is confusing. We should remove it for the numeric arithmetic operations and have a new error class for the interval division error: "INTERVAL_DIVIDED_BY_ZERO"
Why are the changes needed?
For better error messages
Does this PR introduce any user-facing change?
Yes, Use different error classes for numeric/interval divided by 0. After changes, the error messages are simpler and more clear.
How was this patch tested?
UT