You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@avro.apache.org by "Marcio Silva (JIRA)" <ji...@apache.org> on 2012/11/14 05:12:16 UTC

[jira] [Updated] (AVRO-1204) Schema.createUnion can produce schemas that aren't parseable due to redefinition of types

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

Marcio Silva updated AVRO-1204:
-------------------------------

    Attachment: 0001-Creating-test-case-to-illustrate-Union-schema-proble.patch

A patch that contains a junit test that illustrates the problem.
                
> Schema.createUnion can produce schemas that aren't parseable due to redefinition of types
> -----------------------------------------------------------------------------------------
>
>                 Key: AVRO-1204
>                 URL: https://issues.apache.org/jira/browse/AVRO-1204
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.3
>            Reporter: Marcio Silva
>         Attachments: 0001-Creating-test-case-to-illustrate-Union-schema-proble.patch
>
>
> Schemas returned from {{Schema.createUnion}} aren't always re-parsable (after calling Schema.toString()).
> If you create a union of types that contain multiple references to the same type, the resulting {{Schema}} instance returned can't be written to JSON and then re-parsed due to a SchemaParseException on type redefinition.
> The fix probably involves changes to {{UnionSchema.toJson}} to ensure that any repeated type definitions are replaced by a named reference.
> For a concrete example, the union of the following two schemas is problematic:
> {code:javascript|title=child-schema.avsc}
> {"type":"record",
>  "name":"UnionTestChild",
>  "namespace":"org.apache.avro",
>  "fields":[
>                { "name":"intField","type":"int"},
>                { "name":"stringField", "type":"string"}
>            ]
> }
> {code}
> {code:javascript|title=parent-schema.avsc}
> {
>    "type":"record",
>    "name":"UnionTestParent",
>    "namespace":"org.apache.avro",
>    "fields":[
>       {
>          "name":"child",
>          "type":{
>             "type":"record",
>             "name":"UnionTestChild",
>             "namespace":"org.apache.avro",
>             "fields":[
>                { "name":"intField","type":"int"},
>                { "name":"stringField", "type":"string"}
>             ]
>          }
>       }
>    ]
> }
> {code}

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira