dannycjones commented on code in PR #4324:
URL: https://github.com/apache/iceberg-python/pull/4324#discussion_r4526001747


##########
pyiceberg/manifest.py:
##########
@@ -736,6 +736,12 @@ def update(self, value: Any) -> None:
             else:
                 self._max = max(self._max, value)
                 self._min = min(self._min, value)
+                if isinstance(value, float) and value == 0.0:
+                    # min and max keep whichever zero came first, but bounds 
must order -0.0 below 0.0
+                    if math.copysign(1.0, value) < 0 and self._min == 0.0:
+                        self._min = value
+                    elif math.copysign(1.0, value) > 0 and self._max == 0.0:
+                        self._max = value

Review Comment:
   I think we could do better readability here, but I'm not sure on any impact 
to performance in Python. Not suggesting we make this change, just noting a 
possible alternative.
   
   
   ```suggestion
                   def _bounds_order(value: Any) -> Any:
                       # Spec requires IEEE 754 totalOrder: 
https://iceberg.apache.org/spec/#bounds-for-float-and-double
                       # For float, use (value, sign) as the key to compare.
                   return (value, math.copysign(1.0, value)) if 
isinstance(value, float) else value
   
   
                   self._max = max(self._max, value, key=_bounds_order)
                   self._min = min(self._min, value, key=_bounds_order)
   ```



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