You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@avro.apache.org by Michael San Soucie <sa...@gmail.com> on 2016/04/08 17:25:17 UTC

"SchemaParseException: No type" when creating a union within an array

Hello,

New to Avro, so apologies if the following is a misinformed question.

I'm hoping to create a schema where an array can be composed of items of a
set number of complex types.

The problem section looks something like the following:
{
      "name": "ARRAY_OF_ITEMS",
      "type": {
        "type": "array",
        "items": {
          "type": [
            {
              "name": "FIRST_OPTION",
              "type": "record",
              "fields": [
                {
                  "name": "SOME_FIELD",
                  "type": "string"
                }
              ]
            },
            {
              "name": "SECOND_OPTION",
              "type": "record",
              "fields": [
                {
                  "name": "SOME_FIELD",
                  "type": "string"
                }
              ]
            }
          ]
        }
      }
    }

For whatever reason, Avro, doesn't seem to like my union declaration, which
is composed of complex types as opposed to primitives.

Further, I'm not even sure an array's items can be defined as union. I
couldn't find any information about this in the documentation.

I'd love any insights on how to accomplish creating an array composed of
multiple possible types.

Thanks for any help or insights,

Michael