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

Doug Cutting commented on AVRO-1274:
------------------------------------

This should look like:

{"name":"optionalBytesWithDefault", "type":["null", "bytes"], "default":null}

If a field's type is a union, then the type of the default is the type of the 
first element in the union.  So the only valid default value for a union of the 
form ["null", ...] is null.  Some other valid examples of unions with defaults 
are:

{"name":"f1", "type":["string", "int"], "default":""}
{"name":"f2", "type":["int", "string"], "default":0}

Default values are different than what JsonEncoder would produce.  It will 
qualify values of a union with their type, rendering {"bytes":"foo"} rather 
than just "foo" for a value whose schema is ["bytes", ...].  But default values 
are not so qualified.

Does that help?
                
> Add a schema builder API
> ------------------------
>
>                 Key: AVRO-1274
>                 URL: https://issues.apache.org/jira/browse/AVRO-1274
>             Project: Avro
>          Issue Type: New Feature
>          Components: java
>            Reporter: Tom White
>            Assignee: Tom White
>         Attachments: AVRO-1274.patch, AVRO-1274.patch, AVRO-1274.patch
>
>
> It would be nice to have a fluent API that made it easier to construct record 
> schemas.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to