You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "ASF subversion and git services (Jira)" <ji...@apache.org> on 2021/12/11 14:33:00 UTC

[jira] [Commented] (AVRO-2976) IDL parsing does not support arbitrary logical types

    [ https://issues.apache.org/jira/browse/AVRO-2976?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17457619#comment-17457619 ] 

ASF subversion and git services commented on AVRO-2976:
-------------------------------------------------------

Commit 0e74de1eedc90418731d14ce51528b84dc3caf24 in avro's branch refs/heads/master from Oscar Westra van Holthe - Kind
[ https://gitbox.apache.org/repos/asf?p=avro.git;h=0e74de1 ]

AVRO-2976: Add LogicalType parsing to the IDL (#985)

* AVRO-2976: Add LogicalType parsing to IDL

* AVRO-2976: Handle both Long and Integer in IDL JSON parsing

The IDL parser now distinguishes numbers between Long and Integer. This
is needed because the logical type decimal breaks on Long numbers for
precision and scale.

I chose to solve it here because the scope of this change is smaller. An
alternative is to downcast a Long in the method
LogicalTypes.Decimal#getInt(Schema, String).

* AVRO-2976: Remove duplicate annotation processing for types.

* Extend simple test to also verify annotations on arrays (the grammar alrewady supports this).

* AVRO-2976: Trigger tests (build fail on unrelated part)

* AVRO-2976: Revert pom.xml change.

* AVRO-2976: Fix copy/paste error

* AVRO-2976: Remove debugging code

The removed code was used to evaluate if the test would work.

* AVRO-2976: Spotless

* AVRO-2976: Fix test

The test worked because calling toString() on the protocol made schemas
available by their unqualified name (without namespace).

> 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 50m
>  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)