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

        

Reply via email to