On 02/11/2011 12:08 PM, Scott Carey wrote:
Yes, that is a common mistake. Try:{"type":"record","name":"outer","fields":[{"name":"a","type":{"type":"array ","items":"string"}}]} The problem is that "a" is a field, and the field's name is "a". Arrays don't have names, they are a nameless type. Therefore, without the nesting the "items" part applies to the field, not the array, but it is an array property. Another way to think about it is that "string" is shorthand for {"type":"string"}. Likewise, if you declare and name a record, you can simply reference its name after "type": afterwards. "string" is a built-in name. If there is a bug here, it is that the error message is not that clear to someone new with Avro. In Java, this error now has the message: org.apache.avro.SchemaParseException: "array" is not a defined name. The type of the "a" field must be a defined name or a {"type": ...} expression.
Thanks very much, Scott. I see that this is a common problem, as someone else just posted with the exact same issue :) I also got help from Doug Cutting on IRC about this; thanks to both of you.
-Scott
-- Christopher Armstrong, id Software
