xinrong-meng opened a new pull request, #51407:
URL: https://github.com/apache/spark/pull/51407

   ### What changes were proposed in this pull request?
   Fix float32 type widening in `rmod` under ANSI, 
   
   
   ### Why are the changes needed?
   Ensure pandas on Spark works well with ANSI mode on.
   Part of https://issues.apache.org/jira/browse/SPARK-52700.
   
   In pandas, when performing mod or rmod operations involving a float32 and 
other numeric types (e.g., int, float64), the result retains the float32 dtype; 
but pandas on spark widen to float64
   
   **Pandas**
   ```py
   >>> s
   0    1.1
   1    2.2
   2    3.3
   dtype: float32
   >>> s % 1
   0    0.1
   1    0.2
   2    0.3
   dtype: float32
   >>> 1 % s
   0    1.0
   1    1.0
   2    1.0
   dtype: float32
   >>> s % 0.1
   0    7.450581e-09
   1    1.490116e-08
   2    9.999990e-02
   dtype: float32
   >>> 0.1 % s
   0    0.1
   1    0.1
   2    0.1
   dtype: float32
   ```
   
   **Pandas on Spark**
   ```py
   >>> psser
   0    1.1
   1    2.2
   2    3.3
   dtype: float32
   >>> psser % 1
   0    0.1
   1    0.2
   2    0.3
   dtype: float64
   >>> 1 % psser
   0    1.0
   1    1.0
   2    1.0
   dtype: float64
   >>> psser % 0.1
   0    2.384186e-08
   1    4.768372e-08
   2    9.999995e-02
   dtype: float64
   >>> 0.1 % psser
   0    0.1
   1    0.1
   2    0.1
   dtype: float64
   ```
   
   ### Does this PR introduce _any_ user-facing change?
   Yes, both `rmod` and `mod` work as expected under ANSI
   
   
   ### How was this patch tested?
   Unit tests
   
   
   ### Was this patch authored or co-authored using generative AI tooling?
   No


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