avro-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ryan Blue (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (AVRO-1569) ReflectData.AllowNull fails with polymorphism
Date Tue, 10 Mar 2015 16:15:38 GMT

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

Ryan Blue commented on AVRO-1569:
---------------------------------

It looks like this is probably caused by the added union in the schema. I'm not clear on why
your solution, to reflect the data from parents and check those is the right solution. When
resolving the union, we just need to match the non-null case. Do you know what the two schemas
are at that point and why the match isn't succeeding?

This may be related to AllowNull problems that were fixed earlier but haven't been released
yet. See AVRO-1590.

> ReflectData.AllowNull fails with polymorphism
> ---------------------------------------------
>
>                 Key: AVRO-1569
>                 URL: https://issues.apache.org/jira/browse/AVRO-1569
>             Project: Avro
>          Issue Type: Bug
>    Affects Versions: 1.7.6
>            Reporter: Sachin Goyal
>
> UnresolvedUnionException is thrown if the following structure is serialized with ReflectData.AllowNull
> (Plain ReflectData works fine)
> {code}
> class Base 
> {
>    Integer a = 5;
> }
> class Derived extends Base
> {
>     String b = "Foo";
> }
> class PolymorphicDO
> {
>    Base obj = new Derived();
> }
> // Serialization code:
> ReflectData rdata = ReflectData.AllowNull.get();
> Schema schema = rdata.getSchema(PolymorphicDO.class);
> ReflectDatumWriter<T> datumWriter = new ReflectDatumWriter (PolymorphicDO.class,
rdata);
> DataFileWriter<T> fileWriter = new DataFileWriter<T> (datumWriter);
> fileWriter.create(schema, new ByteArrayOutputStream());
> fileWriter.append(new PolymorphicDO());
> {code}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message