avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: how to implement inheritance in Avro
Date Tue, 28 May 2013 22:41:41 GMT
You can put these all in one file by putting square brackets around
the three schemas and commas between them, so that it is interpreted
as a union schema.  Or you can put them in three separate files and
list them in order on the compile tool's command line.  Or you can add
an import containing the Shape schema
(https://issues.apache.org/jira/browse/AVRO-1188).  I hope one of
these is applicable to your case.

Doug

On Tue, May 28, 2013 at 3:18 PM, Mika Ristimaki
<mika.ristimaki@gmail.com> wrote:
> Hi all,
>
> I've been struggling to get some sort of inheritance model to work with Avro but I've
not been very successful at it. So maybe someone in hear can give me a pointer. What I've
been trying to do is to define schemas like this
>
>
> {"namespace": "com.test",
>  "type": "record",
>  "name": "Shape",
>  "fields": [
>      {"name": "colour", "type": "string"}
>  ]
> }
>
> {"namespace": "com.test",
>  "type": "record",
>  "name": "Circle",
>  "fields": [
>      {"name": "radius", "type": "int"},
>      {"name": "super", "type": "com.test.Shape"}
>  ]
> }
>
> {"namespace": "com.test",
>  "type": "record",
>  "name": "Square",
>  "fields": [
>      {"name": "width", "type": "int"},
>      {"name": "super", "type": "com.test.Shape"}
>  ]
> }
>
> When I try to generate classes from this I get "org.apache.avro.SchemaParseException:
"com.test.Shape" is not a defined name". So what is a defined name and where I define it?
I tried to put everything into the same file but that didn't work. I also tried to play around
with unions but couldn't get the schema syntax right. Any help with this would be greatly
appreciated and also other patterns for implementing inheritance with Avro are interesting.
>
> Thanks for any help!!
>
> -Mika

Mime
View raw message