RonakkGovani commented on PR #60249: URL: https://github.com/apache/spark/pull/60249#issuecomment-6793216545
Thanks for the thorough review. I reproduced the two main findings before changing anything: five chained `% 3` grew the analyzed plan from 541 to 611,299 characters, and `monotonically_increasing_id() % 3` returned `[0, 0, 1, 1, 2, 0]`. 47afe3e follows Shared repair plan 1. It adds an internal `PandasMod` Catalyst expression (`pandas_mod`), modeled on `Pmod`, and `_python_mod` now calls it: - **Decimal types (P1):** the result type is that of `((left % right) + right) % right` under the session's decimal settings, and the exact result is rounded half-up once. Tests cover `decimal(38,18)`, `decimal(18,2)` and mixed precision, both values of `allowPrecisionLoss`, and `retainFractionDigitsOnTruncate`. - **Nondeterministic operands, chained plan growth and the ANSI guard (P1, P1, P2):** each operand is a single child evaluated once per row, and a zero or null divisor gives null in both modes, so the guards in `mod` and `rmod` are gone. Over five chained modulo operations the plan now grows 4x, against 6.9x on master. - **NumPy scalars (P2):** a NumPy scalar operand is taken as the Python number it holds, as the Column operators did. - **Zero-sign test (P3):** it now uses exact negative multiples and `-0.0`, covers the reflected and Series % Series forms, and compares signs only where pandas returns zero. The new pandas-on-Spark tests fail on the previous version of this PR. I left the floor-division helper as it is, as the review suggests. -- 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]
