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

Anders Sundelin commented on AVRO-2072:
---------------------------------------

I have reviewed your patch, [~nkollar], and it certainly looks OK with me. All 
the relevant test cases are there, and you updated the failing ones, like you 
said.
My only gripe is that the case statements are on the same line (this was also 
the case before your patch, so I understand why you kept the style). This is 
not according to the Avro conventions (which says that Sun Java conventions, 
with two-space indent) shall be used.
Also, I think that the method "ResolvingGrammarGenerator.bestBranch" does not 
really live up to its name - it will find the first matching branch, not 
necessarily the best one (e.g. when the writer schema is [long] and the reader 
is [float, double], in that order, it will pick float to read the value, 
instead of double, which would prevent data-loss. Easily verified by the 
following test case (placed in TestReadingWritingDataInEvolvedSchemas):
{{
@Test
  public void longIsReadByUnionFloatDoubleSchema() throws Exception {
    Schema writer = LONG_RECORD;
    Record record = defaultRecordWithSchema(writer, FIELD_A, 42L);
    byte[] encoded = encodeGenericBlob(record);
    assertEquals(42.0f, decodeGenericBlob(UNION_FLOAT_DOUBLE_RECORD, writer, 
encoded).get(FIELD_A));
  }
}}
But this method was called that before your patch as well, so I would not fail 
the patch because of this.
+1 from me 


> ResolvingGrammarGenerator doesn't implement schema resolution correctly for 
> unions
> ----------------------------------------------------------------------------------
>
>                 Key: AVRO-2072
>                 URL: https://issues.apache.org/jira/browse/AVRO-2072
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.7, 1.8.1
>            Reporter: Nandor Kollar
>            Assignee: Nandor Kollar
>         Attachments: 0001-AVRO-1931-Additional-test-cases.patch, 
> AVRO-2072_2.patch, AVRO-2072.patch
>
>
> According to 
> [specification|https://avro.apache.org/docs/current/spec.html#Schema+Resolution],
>  int and long is promotable to float, but when using SchemaValidator, a union 
> with a single int or long branch is not readable by an union with a float 
> branch.



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to