avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: optional array in avro
Date Thu, 23 Feb 2012 18:19:45 GMT
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}


View raw message