zhengruifeng commented on code in PR #58319:
URL: https://github.com/apache/spark/pull/58319#discussion_r3867878897


##########
python/pyspark/pandas/numpy_compat.py:
##########
@@ -152,17 +152,29 @@ def _copysign_func(c1: Column, c2: Column) -> Column:
 def _fmod_func(c1: Column, c2: Column) -> Column:
     c1_double = c1.cast("double")
     c2_double = c2.cast("double")
+    integral_types = ["tinyint", "smallint", "int", "bigint"]
 
+    # Dispatched on type twice: floating operands need a NaN for a zero 
divisor, and among the
+    # rest, at the end of the branch below, only integral operands can take 
the remainder in
+    # integer space.
     return F.when(
         F.typeof(c1).isin("float", "double") | F.typeof(c2).isin("float", 
"double"),
         F.when(c1.isNull() | F.isnan(c1), c1_double)
         .when(c2.isNull() | F.isnan(c2), c2_double)
         .when(c2_double == 0, F.lit(float("nan")))
         .otherwise(F.try_mod(c1_double, c2_double)),
     ).otherwise(
+        # Non-floating operands, where NumPy normalizes a zero divisor to 0 
instead of a NaN.

Review Comment:
   will numpy raise a error for types like string



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