avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Scott Carey (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1017) org.apache.avro.generic.GenericData.resolveUnion does not deal correctly with a union of two records with (different) namespace definitions
Date Mon, 06 Feb 2012 23:34:59 GMT

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

Scott Carey commented on AVRO-1017:
-----------------------------------

Avro should be able to have a union of two different records with two different namespaces.
 So if this is not user error, it is a bug.  Sample code or a unit test with the error condition
would help.

I may have time to try this myself within the next couple days.
                
> org.apache.avro.generic.GenericData.resolveUnion does not deal correctly with a union
of two records with (different) namespace definitions
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: AVRO-1017
>                 URL: https://issues.apache.org/jira/browse/AVRO-1017
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.6.1
>            Reporter: Joseph Adler
>
> Suppose that you define two different avro objects:
> {"name":"A", "namespace":"com.something", "type":"record", ...}
> {"name":"B", "namespace":"com.anotherthing", "type":"record", ...}
> Then define a union of the two:
> {"name":"bothAAndB", "type":[{"name":"A", "namespace":"com.something", "type":"record",
...},{"name":"B", "namespace":"com.anotherthing", "type":"record", ...}]}
> If you write an object of type A or B into a GenericRecord and try to use org.apache.avro.generic.GenericDatumWriter
to store the object, you will get an org.apache.avro.UnresolvedUnionException exception.
> Very specifically, it looks like org.apache.avro.UnionSchema.getIndexNamed is being called
by  org.apache.avro.generic.GenericDatumWriter.resolveUnion with the short name of the record,
but that the org.apache.avro.UnionSchema object contains the full names of the objects. So,
org.apache.avro.UnionSchema.getIndexNamed doesn't find a match and Avro fails to find an object
in the union that matches the object in the datum.
> So... I'd like to see one of two fixes: (1) an informative error message telling me that
I can't form a union of records from different namespaces, or (2) a successful lookup of the
schema and record writing.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Mime
View raw message