You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Łukasz Budnik <lu...@gmail.com> on 2014/12/27 09:51:53 UTC

array of complex type

Hi all,

I have a very simple question. I would like to create schema for test run
object which contains a list of test cases.

I’m using gradle plugin v1.7.2 from Spring source so I realise that I may
not have the latest functionality (althought the avro compiler is set to
1.7.7).

I have such avsc file:

{
  "namespace": "io.github.lukaszbudnik.avro.model",
  "type": "record",
  "name": "TestRunV1",
  "fields": [
    {"name": "name", "type": "string"},
    {"name": "testCasesString",  "type": { "type": "array", "items":
"string" } }
  ]
}

it works without any problems. I get a list of strings (char sequence) as
testCasesString. But that’s not what I really want. I want a list of
TestCase objects. In my other avsc file I have:

{
  "namespace": "io.github.lukaszbudnik.avro.model",
  "type": "record",
  "name": "TestCaseV1",
  "fields": [
    {"name": "name", "type": "string"}
  ]
}

Above schema parses OK and I have TestCaseV1 class generated. So I have
TestRunV1 and TestCaseV1 but I would like to link them together and I’m
struggling a lot with adding the following field to TestRunV1 object:

{"name": "testCases",  "type": { "type": "array", "items": { "type":
"TestRunV1" } } }

I keep getting "Type not supported: TestCaseV1”. When I change type to
“TestRunV1” (just like in the documentation there is a example of linked
list definition) I also get error: "Type not supported: TestRunV1”.

I also tried prefixing type with the namespace with no luck.

I’m pretty sure I have a very simple mistake somewhere, but I just can’t
see it. Could you tell me what am I doing wrong?

thanks,
Łukasz

Re: array of complex type

Posted by Łukasz Budnik <lu...@gmail.com>.
Hi all,

So it was all due to org.apache.avro:avro-gradle-plugin:1.7.2 plugin. When
I switched to com.commercehub.gradle.plugin:gradle-avro-plugin:0.3.4 all
worked like a charm.

If anyone would be interested in a working gradle project with avro
evolutions tests using specific reader/writer its pushed to my github repo:
https://github.com/lukaszbudnik/avro-evolutions.

thanks,
Łukasz

On 27 December 2014 at 09:51, Łukasz Budnik <lu...@gmail.com> wrote:

> Hi all,
>
> I have a very simple question. I would like to create schema for test run
> object which contains a list of test cases.
>
> I’m using gradle plugin v1.7.2 from Spring source so I realise that I may
> not have the latest functionality (althought the avro compiler is set to
> 1.7.7).
>
> I have such avsc file:
>
> {
>   "namespace": "io.github.lukaszbudnik.avro.model",
>   "type": "record",
>   "name": "TestRunV1",
>   "fields": [
>     {"name": "name", "type": "string"},
>     {"name": "testCasesString",  "type": { "type": "array", "items":
> "string" } }
>   ]
> }
>
> it works without any problems. I get a list of strings (char sequence) as
> testCasesString. But that’s not what I really want. I want a list of
> TestCase objects. In my other avsc file I have:
>
> {
>   "namespace": "io.github.lukaszbudnik.avro.model",
>   "type": "record",
>   "name": "TestCaseV1",
>   "fields": [
>     {"name": "name", "type": "string"}
>   ]
> }
>
> Above schema parses OK and I have TestCaseV1 class generated. So I have
> TestRunV1 and TestCaseV1 but I would like to link them together and I’m
> struggling a lot with adding the following field to TestRunV1 object:
>
> {"name": "testCases",  "type": { "type": "array", "items": { "type":
> "TestRunV1" } } }
>
> I keep getting "Type not supported: TestCaseV1”. When I change type to
> “TestRunV1” (just like in the documentation there is a example of linked
> list definition) I also get error: "Type not supported: TestRunV1”.
>
> I also tried prefixing type with the namespace with no luck.
>
> I’m pretty sure I have a very simple mistake somewhere, but I just can’t
> see it. Could you tell me what am I doing wrong?
>
> thanks,
> Łukasz
>