rdtr opened a new pull request, #13170:
URL: https://github.com/apache/gluten/pull/13170

    ## What changes are proposed in this pull request?
   
   This continues https://github.com/apache/gluten/pull/12192, which looks 
stale and upstream changes now require an overhaul so I created a separate PR 
here.
   
     With `spark.sql.ansi.enabled=true` and ANSI fallback disabled, decimal 
Add, Subtract and Multiply return NULL on overflow instead of throwing. For 
example:
   
         SELECT CAST(99999999999999999999999999999999999999 AS DECIMAL(38,0)) + 
CAST(1 AS DECIMAL(38,0))
   
     returns NULL on Velox, and Spark then fails with `NullPointerException` 
while decoding the non-nullable result.
   
     #12192 handled this in a `CheckOverflow(BinaryArithmetic, ...)`. On Spark 
3.4+, `CheckOverflow` no longer wraps arithmetic (see #13002). This PR instead 
passes the arithmetic expression to `getDecimalArithmeticExprName`, as 
@philo-he suggested on #12192. The Velox backend maps ANSI-mode decimal Add, 
Subtract and Multiply to Velox's `checked_add`, `checked_subtract` and 
`checked_multiply`, which throw on overflow.
   
   The ClickHouse and Bolt backends keep their current function names. TRY mode 
is unchanged, because the regular decimal functions already return NULL on 
overflow.
   
     Part of #10134.
   
     ## How was this patch tested?
   
     Added decimal overflow and `try_*` tests to `ArithmeticAnsiValidateSuite`, 
which runs with ANSI fallback disabled, including a test with 
`allowPrecisionLoss` disabled that also
     checks the query runs on Velox. The overflow tests fail without this 
change.
   
     ## Was this patch authored or co-authored using generative AI tooling?
   
     Generated-by: Claude Code (Claude Opus 5.5)
   


-- 
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]

Reply via email to