You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@iceberg.apache.org by GitBox <gi...@apache.org> on 2022/10/06 18:55:04 UTC

[GitHub] [iceberg] rdblue commented on a diff in pull request #5928: API: Handle negative/zero during num-digits calculation

rdblue commented on code in PR #5928:
URL: https://github.com/apache/iceberg/pull/5928#discussion_r989383675


##########
api/src/main/java/org/apache/iceberg/expressions/ExpressionUtil.java:
##########
@@ -291,7 +291,9 @@ private static String sanitize(Literal<?> literal) {
   }
 
   private static String sanitizeNumber(Number value, String type) {
-    int numDigits = (int) Math.log10(value.doubleValue()) + 1;
+    // log10 of zero isn't defined and will result in negative infinity
+    int numDigits =
+        0.0d == value.doubleValue() ? 1 : (int) Math.log10(Math.abs(value.doubleValue())) + 1;

Review Comment:
   Good point. Right now, this is summarizing the numeric value, even if that's outside the range of actual digits we'd be able to store because of precision. I think it's probably fine for now though?



-- 
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: issues-unsubscribe@iceberg.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@iceberg.apache.org
For additional commands, e-mail: issues-help@iceberg.apache.org