ninglinLiu opened a new pull request, #7218: URL: https://github.com/apache/datafusion-comet/pull/7218
## Which issue does this PR close? Closes #7216. ## Rationale for this change Under ANSI mode the native string-to-decimal cast raises `SparkError::NumericOutOfRange` for values such as `'0e38'`. None of the `ShimSparkErrorConverter`s had a `"NumericOutOfRange"` case, so `SparkErrorConverter` fell through to a plain `SparkException`. Spark throws a `SparkArithmeticException` here, so code catching `ArithmeticException` behaved differently with Comet enabled. The error class, SQLSTATE and message were already the same. ## What changes are included in this PR? Each shim now maps `NumericOutOfRange` to Spark's own `outOfDecimalTypeRangeError(value)`: - `spark-4.x`: `DataTypeErrors.outOfDecimalTypeRangeError` (where Spark 4.x defines it) - `spark-3.4` and `spark-3.5`: `QueryExecutionErrors.outOfDecimalTypeRangeError` That is the same helper `Decimal.fromStringANSI` uses, so the exception type, error class `NUMERIC_OUT_OF_SUPPORTED_RANGE` and the `value` parameter all match Spark. ## How are these changes tested? - New `SparkErrorConverterSuite` test converts a native `NumericOutOfRange` JSON error and checks that the result is a `SparkArithmeticException` (and an `ArithmeticException`) with error class `NUMERIC_OUT_OF_SUPPORTED_RANGE` and `value = 0e38`. - The suite passes with `-Pspark-4.1`, `-Pspark-3.5` and `-Pspark-3.4`. Without the shim change the new test fails on Spark 4.1 (`SparkException` instead of `SparkArithmeticException`). - `spotless:apply` run. This PR was prepared with AI assistance and reviewed and tested by the author. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
