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

dennis lucero commented on AVRO-1400:
-------------------------------------

I tried the workaround {code:java}@AvroMeta(key="default", 
value="null"){code}but this is actually forbidden:
{code}org.apache.avro.AvroRuntimeException: Can't set reserved property: default
        at org.apache.avro.JsonProperties.addProp(JsonProperties.java:81)
        at org.apache.avro.JsonProperties.addProp(JsonProperties.java:67)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:484)
        at 
org.apache.avro.reflect.ReflectData.getAnnotatedUnion(ReflectData.java:527)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:440)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:377)
        at 
org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:577)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:467)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:377)
        at 
org.apache.avro.reflect.ReflectData.createFieldSchema(ReflectData.java:577)
        at 
org.apache.avro.reflect.ReflectData.createSchema(ReflectData.java:467)
        at 
org.apache.avro.specific.SpecificData.getSchema(SpecificData.java:188){code}

> Introduce annotation to specify default values
> ----------------------------------------------
>
>                 Key: AVRO-1400
>                 URL: https://issues.apache.org/jira/browse/AVRO-1400
>             Project: Avro
>          Issue Type: Improvement
>          Components: java
>    Affects Versions: 1.7.5
>            Reporter: dennis lucero
>              Labels: annotation, features, reflection, schema
>
> It would be nice if there was an annotation in org.apache.avro.reflect to 
> specify default values for schemata derived reflectively, allowing for proper 
> schema evolution.
> I suggest the following:
> {code:java}
> @AvroDefault(1)
> int someNum;
> @Nullable
> @AvroDefault(null)
> AnotherRecord myRec;
> {code}



--
This message was sent by Atlassian JIRA
(v6.1#6144)

Reply via email to