|
|
-
Re: optional array in avroDoug Cutting 2012-02-23, 18:19
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} Doug |