gengliangwang opened a new pull request, #56232: URL: https://github.com/apache/spark/pull/56232
### What changes were proposed in this pull request? `Pmod.doGenCode` emitted the positive-modulo `remainder`/adjust block inline, once for byte/short and once for the int/long/float/double case (~6-8 lines each), duplicating the algorithm already implemented by `Pmod`'s private `pmod` eval methods. This adds `MathUtils.pmod` overloads (Int, Long, Byte, Short, Float, Double) -- the exact bodies moved out of `Pmod` -- and routes both the eval dispatch (`pmodFunc`) and codegen through them. The primitive codegen cases collapse to a single `MathUtils.pmod(left, right)` call. The Decimal case (which returns null / applies `toPrecision`) is unchanged. ### Why are the changes needed? Part of SPARK-56908 (umbrella). `Pmod` over IntegerType is emitted by every `HashPartitioning` (`Pmod(Murmur3Hash(...), numPartitions)`), so collapsing the inline block shrinks the generated Java on a very common path, and the eval and codegen paths now share one implementation instead of duplicating the algorithm (helping with the JVM 64KB method / constant-pool limits, Janino compile time, and JIT work). ### Does this PR introduce _any_ user-facing change? No. The compiled behavior is identical; only the emitted Java source text changes. ### How was this patch tested? Existing `ArithmeticExpressionSuite."pmod"` covers all numeric types, negative operands / divisors, mod-by-zero (ANSI on/off), and `checkConsistencyBetweenInterpretedAndCodegenAllowingException` across all numeric types (which verifies eval and codegen agree -- exactly the invariant this refactor must preserve). ``` build/sbt "catalyst/testOnly *ArithmeticExpressionSuite" ``` 35/35 pass. ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Code (Opus 4.8) -- 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]
