CODERNSINGH commented on code in PR #60233:
URL: https://github.com/apache/spark/pull/60233#discussion_r4547904857


##########
python/pyspark/eval_handlers/_udtf.py:
##########
@@ -71,6 +72,25 @@
     from pyspark.worker_util import EvalConf, RunnerConf
 
 
+def _partition_values_equal(left: Any, right: Any) -> bool:
+    """
+    Compare two partition key values the way Spark groups them, treating NaN 
as equal to NaN
+    (also when nested inside rows, structs, arrays or maps). Python's ``!=`` 
is not enough,
+    since ``float("nan") != float("nan")`` is True.
+    """
+    if isinstance(left, float) and isinstance(right, float):

Review Comment:
   Good catch, thanks! I changed the scalar fallback to `left != left and right 
!= right`, so any NaN leaf is equal, including `numpy.float32`. I also added an 
`array<float>` key to the shared `BaseUDTFTestsMixin` NaN test. On the previous 
head it fails on the legacy pandas variant (`[1, 1, 2]` instead of `[2, 2]`), 
and it passes now.
   



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