avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Francis Galiegue <fgalie...@gmail.com>
Subject Re: Question about Avro "records"
Date Wed, 27 Feb 2013 22:52:59 GMT
On Wed, Feb 27, 2013 at 11:21 PM, Pankaj Shroff <shroffg@gmail.com> 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, fgaliegue@gmail.com
JSON Schema in Java: http://json-schema-validator.herokuapp.com

Mime
View raw message