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

Doug Cutting commented on AVRO-2152:
------------------------------------

Aliases are implemented by Schema#applyAliases, not during parsing.

But I think the bug is perhaps with your test case.  The JsonDecoder should be 
constructed with the writer's schema, not the reader's, since you're decoding 
data that was encoded with that schema.  The GenericDatumReader then adapts the 
decoded data to the desired reader schema, including applying any aliases.  
Does that make sense?

> JsonDecoder fails when reading record with aliases inside union
> ---------------------------------------------------------------
>
>                 Key: AVRO-2152
>                 URL: https://issues.apache.org/jira/browse/AVRO-2152
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.8.2
>         Environment: JDK 1.8
> Avro 1.8.2
>            Reporter: Patrick Haas
>            Priority: Major
>         Attachments: JsonDecoderAliasesInUnion.java
>
>
> The JsonDecoder only handles aliases at the "top level" or "field level". 
> Aliased records within a union fail with an "Unknown union branch" 
> AvroTypeException.
>  The same writer/read schema combination works fine with the binaryEncoder, 
> and the two schemas are considered a COMPATIBLE by the SchemaCompatibility 
> check.
>  
> h1. Writer Schema
> {
>  "type" : "record",
>  "name" : "WWrapper",
>  "namespace" : "writer.ns",
>  "doc" : "writer",
>  "fields" : [ {
>  "name" : "item",
>  "type" : [ "null", {
>  "type" : "record",
>  "name" : "WItem",
>  "doc" : "writer item",
>  "fields" : [ {
>  "name" : "value",
>  "type" : "string",
>  "doc" : "value"
>  } ]
>  } ],
>  "doc" : "value"
>  } ]
> }
> h1. Reader Schema
> {
>  "type" : "record",
>  "name" : "RWrapper",
>  "namespace" : "reader.ns",
>  "doc" : "reader",
>  "fields" : [ {
>  "name" : "item",
>  "type" : [ "null", {
>  "type" : "record",
>  "name" : "RItem",
>  "doc" : "reader item",
>  "fields" : [ {
>  "name" : "value",
>  "type" : "string",
>  "doc" : "value"
>  } ],
>  "aliases" : [ "writer.ns.WItem" ]
>  } ],
>  "doc" : "value"
>  } ],
>  "aliases" : [ "writer.ns.WWrapper" ]
> }



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to