Skip to content

Commit f5e6b05

Browse files
mihailom-dbMaxGekk
authored andcommitted
[SPARK-49643][SQL] Merge _LEGACY_ERROR_TEMP_2042 into ARITHMETIC_OVERFLOW
### 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 <[email protected]> Signed-off-by: Max Gekk <[email protected]>
1 parent 31a4117 commit f5e6b05

File tree

4 files changed

+2
-17
lines changed

4 files changed

+2
-17
lines changed

common/utils/src/main/resources/error/error-conditions.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6864,11 +6864,6 @@
68646864
"<methodName> is not implemented."
68656865
]
68666866
},
6867-
"_LEGACY_ERROR_TEMP_2042" : {
6868-
"message" : [
6869-
"<message>. If necessary set <ansiConfig> to false to bypass this error."
6870-
]
6871-
},
68726867
"_LEGACY_ERROR_TEMP_2045" : {
68736868
"message" : [
68746869
"Unsupported table change: <message>"

sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/expressions/intervalExpressions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ case class MakeInterval(
336336
val iu = IntervalUtils.getClass.getName.stripSuffix("$")
337337
val secFrac = sec.getOrElse("0")
338338
val failOnErrorBranch = if (failOnError) {
339-
"throw QueryExecutionErrors.arithmeticOverflowError(e);"
339+
"""throw QueryExecutionErrors.arithmeticOverflowError(e.getMessage(), "", null);"""
340340
} else {
341341
s"${ev.isNull} = true;"
342342
}

sql/catalyst/src/main/scala/org/apache/spark/sql/errors/QueryExecutionErrors.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -599,16 +599,6 @@ private[sql] object QueryExecutionErrors extends QueryErrorsBase with ExecutionE
599599
messageParameters = Map("methodName" -> methodName))
600600
}
601601

602-
def arithmeticOverflowError(e: ArithmeticException): SparkArithmeticException = {
603-
new SparkArithmeticException(
604-
errorClass = "_LEGACY_ERROR_TEMP_2042",
605-
messageParameters = Map(
606-
"message" -> e.getMessage,
607-
"ansiConfig" -> toSQLConf(SQLConf.ANSI_ENABLED.key)),
608-
context = Array.empty,
609-
summary = "")
610-
}
611-
612602
def binaryArithmeticCauseOverflowError(
613603
eval1: Short,
614604
symbol: String,

sql/catalyst/src/test/scala/org/apache/spark/sql/catalyst/expressions/IntervalExpressionsSuite.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ class IntervalExpressionsSuite extends SparkFunSuite with ExpressionEvalHelper {
266266
val intervalExpr = MakeInterval(Literal(years), Literal(months), Literal(weeks),
267267
Literal(days), Literal(hours), Literal(minutes),
268268
Literal(Decimal(secFrac, Decimal.MAX_LONG_DIGITS, 6)))
269-
checkExceptionInExpression[ArithmeticException](intervalExpr, EmptyRow, "")
269+
checkExceptionInExpression[ArithmeticException](intervalExpr, EmptyRow, "ARITHMETIC_OVERFLOW")
270270
}
271271

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

0 commit comments

Comments
 (0)