avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Philipp <philipp.p...@metrigo.de>
Subject optional array in avro
Date Thu, 23 Feb 2012 17:04:14 GMT
I'm wondering whether or not it is possible to have an optional array.
Let's assume a schema like this:

{ "type": "record",
   "name": "test_avro",
   "fields" : [
     {"name": "test_field_1", "type": "long"},
     {"name": "subrecord", "type": [{
       "type": "record",
       "name": "subrecord_type",
       "fields":[{"name":"field_1", "type":"long"}]
     {"name": "simple_array",
         "type": "array",
         "items": "string"

Trying to write an avro record without "simple_array" would result in a 
NPE in the datafilewriter.
For subrecord it's just fine, but when I try to define the array as 

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

It does not result in a NPE but a runtime exception:
AvroRuntimeException: Not an array schema: 


View raw message