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

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


+
Francis Galiegue 2013-02-27, 21:47
+
Pankaj Shroff 2013-02-27, 21:54
+
Francis Galiegue 2013-02-27, 22:14
+
Pankaj Shroff 2013-02-27, 22:21
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
+
Doug Cutting 2013-02-27, 22:20
+
Francis Galiegue 2013-02-27, 22:51
+
Doug Cutting 2013-02-27, 23:10
+
Francis Galiegue 2013-02-27, 23:55
+
Doug Cutting 2013-02-28, 01:12
+
Jeremy Kahn 2013-02-28, 01:30
+
Doug Cutting 2013-02-28, 17:11
+
Francis Galiegue 2013-02-28, 01:40