Skip to content

Conversation

@gengliangwang
Copy link
Member

What changes were proposed in this pull request?

On arithmetic overflow runtime errors, Spark should throw SparkArithmeticException instead of java.lang.ArithmeticException

Why are the changes needed?

Use a better error exception type.

Does this PR introduce any user-facing change?

Yes, trivial change on the exception type: on arithmetic overflow runtime errors, Spark will throw SparkArithmeticException instead of java.lang.ArithmeticException

How was this patch tested?

UT

},
"ARITHMETIC_OVERFLOW": {
"message": ["%s.%s If necessary set %s to false (except for ANSI interval type) to bypass this error.%s"],
"sqlState": "22003"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SQLSTATE Class Condition Subclass Subcondition
22003 22 data exception 003 numeric value out of range

@gengliangwang
Copy link
Member Author

Merging to master/3.3

gengliangwang added a commit that referenced this pull request Mar 31, 2022
…ow runtime errors

### What changes were proposed in this pull request?

On arithmetic overflow runtime errors, Spark should throw SparkArithmeticException instead of `java.lang.ArithmeticException`

### Why are the changes needed?

Use a better error exception type.

### Does this PR introduce _any_ user-facing change?

Yes, trivial change on the exception type: on arithmetic overflow runtime errors, Spark will throw SparkArithmeticException instead of `java.lang.ArithmeticException`

### How was this patch tested?

UT

Closes #36022 from gengliangwang/ArithmeticException.

Authored-by: Gengliang Wang <[email protected]>
Signed-off-by: Gengliang Wang <[email protected]>
(cherry picked from commit b70fa24)
Signed-off-by: Gengliang Wang <[email protected]>
@tgravescs
Copy link
Contributor

question, I haven't kept up with all the error changes, but this only changes 1 place and there are other places in the QueryExecutionErrors that still use the ArtithmeticException, like right above the one you changed:

 def arithmeticOverflowError(e: ArithmeticException): ArithmeticException = {
    new ArithmeticException(s"${e.getMessage}. If necessary set ${SQLConf.ANSI_ENABLED.key} " +
      s"to false to bypass this error.")
  }

is there a reason we are now inconsistent?

@gengliangwang
Copy link
Member Author

@tgravescs Good point.
I found this during working on the project https://issues.apache.org/jira/browse/SPARK-38615. Currently my major focus is still on SPARK-38615.
The method you mentioned seems not to be used anywhere. There are also a few places using ArithmeticException as well. I created https://issues.apache.org/jira/browse/SPARK-38842 as a follow-up.

@tgravescs
Copy link
Contributor

thanks for the clarification and followup @gengliangwang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants