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

Josh Wills commented on AVRO-1274:
----------------------------------

Hey Tom-- I wrote something along these lines way back in the day:

https://github.com/jwills/avroplay/blob/master/src/com/randomgraphs/avro/RecordSchemaBuilder.java

The general orientation is towards supporting the union { null, T } pattern for 
optional fields w/default values, and it ends up looking like:

Schema schema = new RecordSchemaBuilder("myrecord")
    .requiredString("foo")
    .optionalFloat("bar", 17.29f)
    .array("baz", Schema.create(Schema.Type.STRING))
    .build();

It has support for default values for primitive types and just wraps them in 
JsonNodes as need be, and is smart about checking to see if your record is 
named or anonymous. I'm happy to re-format it as a patch if you think it's 
worthwhile. My main feeling was that the name, type, and required/optional 
nature of the field are the three things you really always have to know, and 
whether/not you have a doc string or sort order info should be hidden away as 
rarely-used options in this context.
                
> 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
>
>
> 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