Skip to content

Commit

Permalink
[SPARK-49643][SQL] Merge _LEGACY_ERROR_TEMP_2042 into ARITHMETIC_OVER…
Browse files Browse the repository at this point in the history
…FLOW

### What changes were proposed in this pull request?
Merging related legacy error to its proper class.

### Why are the changes needed?
We want to get remove legacy errors, as they are not properly migrated to the new system of errors. Also, [PR](https://github.com/apache/spark/pull/48206/files#diff-0ffd087e0d4e1618761a42c91b8712fd469e758f4789ca2fafdefff753fe81d5) started getting to big, so this is an effort to split the change needed.

### Does this PR introduce _any_ user-facing change?
Yes, legacy error is now merged into ARITHMETIC_OVERFLOW.

### How was this patch tested?
Existing tests check that the error message stayed the same.

### Was this patch authored or co-authored using generative AI tooling?
No.

Closes #48496 from mihailom-db/error2042.

Authored-by: Mihailo Milosevic <mihailo.milosevic@databricks.com>
Signed-off-by: Max Gekk <max.gekk@gmail.com>
  • Loading branch information
mihailom-db authored and MaxGekk committed Oct 16, 2024
1 parent 31a4117 commit f5e6b05
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 17 deletions.
5 changes: 0 additions & 5 deletions common/utils/src/main/resources/error/error-conditions.json
Original file line number Diff line number Diff line change
Expand Up @@ -6864,11 +6864,6 @@
"<methodName> is not implemented."
]
},
"_LEGACY_ERROR_TEMP_2042" : {
"message" : [
"<message>. If necessary set <ansiConfig> to false to bypass this error."
]
},
"_LEGACY_ERROR_TEMP_2045" : {
"message" : [
"Unsupported table change: <message>"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ case class MakeInterval(
val iu = IntervalUtils.getClass.getName.stripSuffix("$")
val secFrac = sec.getOrElse("0")
val failOnErrorBranch = if (failOnError) {
"throw QueryExecutionErrors.arithmeticOverflowError(e);"
"""throw QueryExecutionErrors.arithmeticOverflowError(e.getMessage(), "", null);"""
} else {
s"${ev.isNull} = true;"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -599,16 +599,6 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
messageParameters = Map("methodName" -> methodName))
}

def arithmeticOverflowError(e: ArithmeticException): SparkArithmeticException = {
new SparkArithmeticException(
errorClass = "_LEGACY_ERROR_TEMP_2042",
messageParameters = Map(
"message" -> e.getMessage,
"ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)),
context = Array.empty,
summary = "")
}

def binaryArithmeticCauseOverflowError(
eval1: Short,
symbol: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
val intervalExpr = MakeInterval(Literal(years), Literal(months), Literal(weeks),
Literal(days), Literal(hours), Literal(minutes),
Literal(Decimal(secFrac, Decimal.MAX_LONG_DIGITS, 6)))
checkExceptionInExpression[ArithmeticException](intervalExpr, EmptyRow, "")
checkExceptionInExpression[ArithmeticException](intervalExpr, EmptyRow, "ARITHMETIC_OVERFLOW")
}

withSQLConf(SQLConf.ANSI_ENABLED.key -> "true") {
Expand Down

0 comments on commit f5e6b05

Please sign in to comment.