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
<[email protected]> 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

Reply via email to