sunchao opened a new pull request, #7730: URL: https://github.com/apache/datafusion-comet/pull/7730
## Which issue does this PR close? Closes #7671. ## Rationale for this change Comet used `IF(x = 0, NULL, x)` for non-ANSI divisors and `IF(x <= 0, NULL, x)` for logarithm arguments. The condition evaluates `x` over the batch. The value branch evaluates it again on the rows that passed the check. For a stateful expression such as `monotonically_increasing_id()`, those evaluations can assign different values to the same row. A divisor that passed the check can then be zero when the arithmetic kernel uses it. ## What changes are included in this PR? - Use a unary native function to check the evaluated operand. It masks zeros for non-ANSI `/`, `div` and `%`, and non-positive values for `ln`, `log10` and `log2`. The math kernel consumes the values the guard checked. Both signs of zero match, and NaNs pass through. - Fold literal divisor checks at planning time. For arrays, the guard updates validity while sharing the values buffer. - Recognize the guard when checking whether an expression is safe to evaluate eagerly. This lets a guarded floating-point division qualify for short-circuit `IN` evaluation when its children qualify. ## How are these changes tested? - A SQL fixture compares all six native operators with Spark using `monotonically_increasing_id()` over a single Parquet file in two-row batches. The arithmetic queries cross a zero divisor, and the logarithm inputs cycle through −1, 0 and 1. - A projection over three rows passes a nondeterministic counting UDF to each operator. The test checks native execution of all six operators and asserts exactly 18 calls to the UDF. - A Rust assertion checks that the planner recognizes guarded division over columns as safe to evaluate eagerly. Local checks cover Rust and Scala formatting and `git diff --check`. Hosted CI runs the test suites. -- 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]
