opwvhk commented on a change in pull request #985:
URL: https://github.com/apache/avro/pull/985#discussion_r763820457



##########
File path: 
lang/java/compiler/src/main/javacc/org/apache/avro/compiler/idl/idl.jj
##########
@@ -1617,7 +1622,14 @@ private JsonNode Json() :
 { String s; Token t; JsonNode n; }
 { 
 ( s = JsonString() { n = new TextNode(s); }
-| (t=<INTEGER_LITERAL> { n = new LongNode(Long.parseLong(t.image)); })
+| (t=<INTEGER_LITERAL> {
+  long longValue = Long.parseLong(t.image);
+  int intValue = (int)longValue;
+  if (intValue == longValue)
+    n = new IntNode(intValue);
+  else
+    n = new LongNode(longValue);
+})

Review comment:
       This bit here creates a JSON node with an Integer in it instead of a 
Long if the number is small enough.
   This is needed because the logical type `decimal` will fail to validate if 
the scale or precision are Long values (even if small enough).




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


Reply via email to