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

Switch to Threaded View
Avro >> mail # user >> optional array in avro

Copy link to this message
Re: optional array in avro
On 02/23/2012 09:04 AM, Philipp wrote:
> For subrecord it's just fine, but when I try to define the array as
> optional:
> {"name": "simple_array",
>     "type":[{
>         "type": "array",
>         "items": "string"
>       }, "null"]
> It does not result in a NPE but a runtime exception:
> AvroRuntimeException: Not an array schema:
> [{"type":"array","items":"string"},"null"]

It's hard to tell exactly what's happening without a complete test case.

What version of Avro are you using?

Also, try specifying the "null" before the array schema in the union and
specify a default value of null, e.g.:

{"name": "simple_array",
 "type": ["null", {"type":"array", "items":"string"}],
 "default": null}