Home | About | Sematext search-lucene.com search-hadoop.com
 Search Hadoop and all its subprojects:

Switch to Threaded View
Avro >> mail # user >> Question about Avro "records"

Copy link to this message
Re: Question about Avro "records"
On Wed, Feb 27, 2013 at 11:21 PM, Pankaj Shroff <[EMAIL PROTECTED]> wrote:
> Yes thats right, and the default value can be "null" - which is what makes
> "b" an "optional" field.
> You can define an optional field by defining it of type "union" in an Avro
> schema where the first type in the union is "null" and the second type is
> "long" or integer in your case.
> Something like this (.avsc or .avpr file would have the following Json):
> {
>     "type": "record",
>     "name": "OptionalFieldsExample",
>     "fields": [
>         {"name": "a",        "type": "long"},
>         {"name": "b", "type": ["null", "long"]},
>         {"name": "c", "type": ["null", "long"]}
>     ]
> }

Is that a reader's or a writer's schema? Sorry for the newbie questions...

Francis Galiegue, [EMAIL PROTECTED]
JSON Schema in Java: http://json-schema-validator.herokuapp.com