sunchao opened a new pull request, #7379: URL: https://github.com/apache/datafusion-comet/pull/7379
## Which issue does this PR close? Closes #7378. ## Rationale for this change With ANSI mode disabled, Spark returns `NULL` for `try_add(a, b) + b` when the inner addition overflows. Comet flattened both additions and rebuilt them using the outer operation's wrapping overflow behavior. The same problem affected `try_multiply` inside a multiplication. ## What changes are included in this PR? Only flatten a nested `Add` or `Multiply` when its evaluation mode matches the parent. This keeps the inner overflow check in the native expression and still balances chains of legacy integer operations. ## How are these changes tested? Added one query to the existing arithmetic SQL fixture covering both operators. With `a = 2147483647` and `b = 1`, the query produced the following results on Spark 4.1.3. | Execution | `try_add(a, b) + b` | `try_multiply(a, a) * b` | | --- | ---: | ---: | | Spark | `NULL` | `NULL` | | Comet before | -2147483647 | 1 | | Comet after | `NULL` | `NULL` | The full `expressions/math/arithmetic.sql` fixture passed on Spark 3.5.9 and 4.1.3. The existing deep integral Add/Multiply chain test also passed on Spark 4.1.3. These runs compiled the changed serializer against cached Apache Comet dependencies and used the existing native library. Spotless passed. -- 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]
