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

O. Reißig updated AVRO-1532:
----------------------------

    Attachment: RemovalOfUnionSubtype.java

Thanks for your suggestion with AvroAlias, that's a lot better than my first 
try :-)

Explicitly stating the schema does indeed resolve the issue with removed 
fields, but now I run into problems with union types. In my schema I have a Map 
containing an abstract type, that has several possible implementations via 
@Union. I'd like the rest of the serialized data to still be readable when 
removing one of the Union subtypes.

I attached a test case to illustrate my example. In the real world, accessing 
the removed type would yield ClassCastException, but of course I cannot 
actually remove a class in this test case. As the stuff is stored in a Map, I 
should still be able to access the rest of the map entries.

Did I make my use case clear? Is this realistic?
Why actually store the schema inside the serialized file, if it is overridden 
anyway? I thought it's better to parse the serialized data with its according 
schema.

> Field deletion not possible for ReflectData: NPE
> ------------------------------------------------
>
>                 Key: AVRO-1532
>                 URL: https://issues.apache.org/jira/browse/AVRO-1532
>             Project: Avro
>          Issue Type: Bug
>          Components: java
>    Affects Versions: 1.7.6
>            Reporter: O. Reißig
>              Labels: java, reflection
>         Attachments: AVRO-1532.patch, ReflectDataFieldRemovalTest.java, 
> ReflectDataFieldRemovalTest.java, RemovalOfUnionSubtype.java
>
>
> *Actual behaviour:*
> I have a field in my reflection-based schema like this:
> {code}
> @Nullable @AvroDefault("null")
> public Long someField;
> {code}
> When removing this field, parsing the previous serialized blob yields 
> NullPointerException:
> {noformat}
> java.lang.NullPointerException
>       at org.apache.avro.reflect.ReflectData.setField(ReflectData.java:128)
>       at 
> org.apache.avro.generic.GenericDatumReader.readField(GenericDatumReader.java:193)
>       at 
> org.apache.avro.reflect.ReflectDatumReader.readField(ReflectDatumReader.java:230)
>       at 
> org.apache.avro.generic.GenericDatumReader.readRecord(GenericDatumReader.java:183)
>       at 
> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:151)
>       at 
> org.apache.avro.generic.GenericDatumReader.read(GenericDatumReader.java:142)
>       at org.apache.avro.file.DataFileStream.next(DataFileStream.java:233)
>       at org.apache.avro.file.DataFileStream.next(DataFileStream.java:220)
>       at 
> ReflectDataFieldRemovalTest.testFieldRemoval(ReflectDataFieldRemovalTest.java:41)
> {noformat}
> *Expected behaviour:*
> Field removal is crucial for schema evolution and must be possible with 
> ReflectData.



--
This message was sent by Atlassian JIRA
(v6.2#6252)

Reply via email to