You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Patrick Haas (JIRA)" <ji...@apache.org> on 2018/03/02 18:37:00 UTC

[jira] [Updated] (AVRO-2152) JsonDecoder fails when reading record with aliases inside union

     [ https://issues.apache.org/jira/browse/AVRO-2152?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Haas updated AVRO-2152:
-------------------------------
    Description: 
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.

    // Writer - Record with embedded "optional" record
    // {
    //  "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"
    //  } ]
    //}
    //
    // Reader - aliases matching the writer names/spaces
    // {
    //  "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" ]
    //}


  was:
{{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.


> 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.
>     // Writer - Record with embedded "optional" record
>     // {
>     //  "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"
>     //  } ]
>     //}
>     //
>     // Reader - aliases matching the writer names/spaces
>     // {
>     //  "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)