kbendick commented on a change in pull request #3332:
URL: https://github.com/apache/iceberg/pull/3332#discussion_r739413295



##########
File path: orc/src/main/java/org/apache/iceberg/orc/OrcMetrics.java
##########
@@ -262,6 +269,16 @@ private static Metrics buildOrcMetrics(final long 
numOfRows, final TypeDescripti
     return Optional.ofNullable(Conversions.toByteBuffer(type, 
truncateIfNeeded(Bound.UPPER, type, max, metricsMode)));
   }
 
+  // ORC uses NaN in its metrics for floating point numbers (float and double).
+  // To avoid storing NaN in the Iceberg metrics, NaN is normalized to +/- 
Infinity for max / min respectively.
+  private static Object normalizeFloatingPointColumnsIfNeeded(Bound bound, 
Type type, double value) {
+    if (type.typeId() == Type.TypeID.DOUBLE) {
+      return Double.isNaN(value) ? (bound == Bound.UPPER ? 
Double.POSITIVE_INFINITY : Double.NEGATIVE_INFINITY) : value;

Review comment:
       Ah that's a good idea. Wasn't a fan of the double ternary.




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