gengliangwang opened a new pull request, #55939:
URL: https://github.com/apache/spark/pull/55939
**Title**: [SPARK-56914][SQL] Refactor decimal arithmetic codegen under ANSI
mode
**Base**: master (stacked on PR 3 - SPARK-56911)
**Head**: gengliangwang:SPARK-56914-decimal-arithmetic
### What changes were proposed in this pull request?
Use `CastUtils.changePrecisionExact` / `changePrecisionOrNull` (added in
SPARK-56911) from the `DecimalType.Fixed` branches of:
* `BinaryArithmetic.doGenCode` (covers `Add` / `Subtract` / `Multiply` on
`Decimal`).
* `BinaryDivModLike.doGenCode` (covers `Divide` / `IntegralDivide` /
`Remainder` / `Pmod` on `Decimal`).
* `BinaryArithmetic.checkDecimalOverflow` (eval path used by both groups via
`numeric.plus`/`minus`/`times`/`div`).
Each call site goes from `eval1.$op(eval2).toPrecision(p, s, ROUND_HALF_UP,
!failOnError, ctx)` + a 4-line null check to a single
`CastUtils.changePrecision{Exact,OrNull}` call.
### Why are the changes needed?
Part of SPARK-56908 (umbrella). Decimal arithmetic is widespread in TPC-DS
plans, and the `BinaryArithmetic` Decimal branch was one of the longer ANSI
codegen bodies still emitted inline.
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
```
build/sbt "catalyst/testOnly *ArithmeticExpressionSuite *DecimalSuite"
```
60/60 pass.
### Was this patch authored or co-authored using generative AI tooling?
Generated-by: Cursor 1.x
--
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]