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/08/15 21:00:33 UTC

[GitHub] [iceberg] kbendick commented on a diff in pull request #5526: Core: Add some tests for JsonUtil & reduce duplicated code

kbendick commented on code in PR #5526:
URL: https://github.com/apache/iceberg/pull/5526#discussion_r946121027


##########
core/src/main/java/org/apache/iceberg/util/JsonUtil.java:
##########
@@ -105,11 +105,11 @@ public static JsonNode get(String property, JsonNode node) {
   }
 
   public static int getInt(String property, JsonNode node) {
-    Preconditions.checkArgument(node.has(property), "Cannot parse missing int %s", property);
+    Preconditions.checkArgument(node.has(property), "Cannot parse missing int: %s", property);
     JsonNode pNode = node.get(property);
     Preconditions.checkArgument(
-        pNode != null && !pNode.isNull() && pNode.isNumber(),
-        "Cannot parse %s to an integer value: %s",
+        pNode != null && !pNode.isNull() && pNode.isIntegralNumber() && pNode.canConvertToInt(),

Review Comment:
   👍 good catch.



##########
core/src/main/java/org/apache/iceberg/util/JsonUtil.java:
##########
@@ -105,11 +105,11 @@ public static JsonNode get(String property, JsonNode node) {
   }
 
   public static int getInt(String property, JsonNode node) {
-    Preconditions.checkArgument(node.has(property), "Cannot parse missing int %s", property);
+    Preconditions.checkArgument(node.has(property), "Cannot parse missing int: %s", property);
     JsonNode pNode = node.get(property);
     Preconditions.checkArgument(
-        pNode != null && !pNode.isNull() && pNode.isNumber(),
-        "Cannot parse %s to an integer value: %s",
+        pNode != null && !pNode.isNull() && pNode.isIntegralNumber() && pNode.canConvertToInt(),
+        "Cannot parse to an integer value: %s: %s",

Review Comment:
   Nit: The usage of double `:` here is a bit odd to me.
   
   Maybe `Cannot parse integer value for property: (%s, %s)`?



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