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

Switch to Threaded View
Avro, mail # user - Nullable Fields


Copy link to this message
-
Re: Nullable Fields
Lewis John Mcgibbney 2014-01-21, 19:21
Hi Alparslan,

On Mon, Jan 20, 2014 at 11:50 AM, Alparslan Avcı
<[EMAIL PROTECTED]>wrote:

>
> Actually, the answer is not quite enough for me, because I wanted to learn
> about why UNION type is used for representing nullable fields in JSON
> schemas.
>

>From my perspective it is simple. At the time I knew of no better way to do
it. Then I found out about default:null, then realized we get NPE when some
data types are null e.g. Map.
> This approach may be used in order to provide other (which I don't know)
> requirements, however I think that a 'nullable' property will suffice
> instead. For example;
>
> {"name": "field1", "type": ["null", {"type":"map", "values":["null",
> "string"]}],"default":null}
>
> can be represented as like
>
> {"name": "field1", "type": {"type":"map", "values":"string",
> "nullable":true}, "nullable":true, "default":null}
>
> Null types in unions will always cause an exceptional situation since they
> are not 'types' at all.
>
> Absolutely. It would be really appreciated if someone (more expereienced
than myself) could determine the concrete differences between the cases
Alparslan has mentioned above. I cannot answer the question right now as I
am still learning more about newer Avro code.
Lewis