Home | About | Sematext search-lucene.com search-hadoop.com
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB
 Search Hadoop and all its subprojects:

Switch to Plain View
Avro >> mail # user >> Avro schema for nested arrays doesn't work


+
Alex Kroifer 2010-09-11, 00:10
Copy link to this message
-
Re: Avro schema for nested arrays doesn't work
Hey Alex,

Inside the "fields" attribute of the "Rec1" record, you can't say "type":
"array"; you need to 1) give the field a name and 2) make "type" be a valid
avro schema, not a valid avro type.

Try:

{"type": "array", "items": {"name": "Rec1", "type": "record", "fields" : [
       {"name": "Array1", "type": {"type": "array", "items": {"name":
"Rec2", "type":"record", "fields" : [
                   {"name": "Scalar", "type": "string"}]}}}]}}

I'd also recommend trying out Avro IDL; it makes writing schemas and
protocols much more pleasant.

Later,
Jeff
On Fri, Sep 10, 2010 at 5:10 PM, Alex Kroifer <[EMAIL PROTECTED]>wrote:

> Avro schema for nested arrays definition doesn't parse:
>
> Schema:
>
> {"type": "array", "items": {"name": "Rec1", "type": "record", "fields" : [
>        {"type": "array", "items": {"name": "Rec2", "type":"record",
> "fields" : [
>                    {"name": "Scalar", "type": "string"}]}}]}}
>
> Result:
>
> No field name:
> {"type":"array","items":{"name":"Rec2","type":"record","fields":[{"name":"Scalar","type":"string"}]}}
> org.apache.avro.SchemaParseException: No field name:
> {"type":"array","items":{"name":"Rec2","type":"record","fields":[{"name":"Scalar","type":"string"}]}}
>         at org.apache.avro.Schema.getRequiredText(Schema.java:981)
>         at org.apache.avro.Schema.parse(Schema.java:907)
>         at org.apache.avro.Schema.parse(Schema.java:934)
>         at org.apache.avro.Schema.parse(Schema.java:813)
>
> What's wrong?
>
> Thank you in advance,
> Alex.
>
NEW: Monitor These Apps!
elasticsearch, apache solr, apache hbase, hadoop, redis, casssandra, amazon cloudwatch, mysql, memcached, apache kafka, apache zookeeper, apache storm, ubuntu, centOS, red hat, debian, puppet labs, java, senseiDB