[
https://issues.apache.org/jira/browse/AVRO-2976?focusedWorklogId=691605&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-691605
]
ASF GitHub Bot logged work on AVRO-2976:
----------------------------------------
Author: ASF GitHub Bot
Created on: 07/Dec/21 09:52
Start Date: 07/Dec/21 09:52
Worklog Time Spent: 10m
Work Description: 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]
Issue Time Tracking
-------------------
Worklog Id: (was: 691605)
Time Spent: 2h 20m (was: 2h 10m)
> IDL parsing does not support arbitrary logical types
> ----------------------------------------------------
>
> Key: AVRO-2976
> URL: https://issues.apache.org/jira/browse/AVRO-2976
> Project: Apache Avro
> Issue Type: Improvement
> Components: java, logical types, tools
> Affects Versions: 1.8.2, 1.10.0, 1.9.2, 1.10.1, 1.10.2
> Reporter: Oscar Westra van Holthe - Kind
> Assignee: Oscar Westra van Holthe - Kind
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.11.1
>
> Attachments: avro2976.zip
>
> Time Spent: 2h 20m
> Remaining Estimate: 0h
>
> When parsing Avro IDL in code, the resulting protocol types (schemas) have no
> logical types defined, when though the properties for them are set.
>
> Example IDL:
> {code:java}
> protocol P {
> record R {
> @logicalType("timestamp-micros") long uTime;
> }
> }{code}
>
> The following test fails on the second assert:
> {code:java}
> @Test
> public void validateIdlLogicalTypeParsing() {
> final ClassLoader cl = Thread.currentThread().getContextClassLoader();
> Idl idl = new Idl(cl.getResourceAsStream("logicalTypes.avdl"), "UTF-8");
> Protocol protocol = idl.CompilationUnit();
> Schema fieldSchema = protocol.getType("R").getField("uTime").schema();
> Assert.assertEquals("timestamp-micros",
> fieldSchema.getObjectProp("logicalType"));
> Assert.assertNotNull(fieldSchema.getLogicalType());
> }
> {code}
>
> A minimal proof is attached.
--
This message was sent by Atlassian Jira
(v8.20.1#820001)