avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Doug Cutting (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (AVRO-1204) Schema.createUnion can produce schemas that aren't parseable due to redefinition of types
Date Fri, 16 Nov 2012 23:37:12 GMT

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

Doug Cutting updated AVRO-1204:
-------------------------------

    Attachment: AVRO-1204.patch

I was able to make this test pass.  I have attached my modified version.

At first it failed in setUp() while parsing the parent schema using a parser that already
had the child schema defined.  So I changed it to create a new parser for each, since the
parent file is a standalone schema and does not refer to the child by name.

Secondly I changed the assertEquals() in assertSchemaParseable() to compare the schema against
its printed and parsed equivalent.

I think these were both bugs in the test, not bugs in Avro.  So, perhaps there is a bug in
Avro you're encountering, but I don't see how this test demonstrates it.
                
> 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.2, 1.7.3
>            Reporter: Marcio Silva
>         Attachments: 0001-Creating-test-case-to-illustrate-Union-schema-proble.patch,
AVRO-1204.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

Mime
View raw message