Avro maven plugin throws No type error for following avro schema

Viewed 207

I am trying to build an avro schema with following structure:

{
    "namespace": "com.myclass.avro",
    "name": "myclass",
    "type": "record",
    "fields": [
        {
            "name": "field1",
            "type": {
                "name": "field2",
                "type": "record",
                "fields": [
                    {
                        "name": "enabletest",
                        "type": "boolean"
                    },
                    {
                        "name": "field3",
                        "type": [
                            "null",
                            {
                                "name": "field3",
                                "type": "map",
                                "values": {
                                    "name": "field3",
                                    "type": [
                                        "null",
                                        {
                                            "name": "field3",
                                            "type": "record",
                                            "fields": [
                                                {
                                                    "name": "address",
                                                    "type": [
                                                        "null",
                                                        "string"
                                                    ],
                                                    "default": null
                                                },
                                                {
                                                    "name": "isPresent",
                                                    "type": [
                                                        "null",
                                                        "boolean"
                                                    ],
                                                    "default": null
                                                }
                                            ]
                                        }
                                    ],
                                    "default": null
                                }
                            }
                        ],
                        "default": null
                    }
                ]
            }
        }
    ]
}

field3 is an optional map whose values are of optional record type. In other words, field3 is a POJO of type Optional<Map<String,Optional<RecordClass>>>. RecordClass contains 2 instance variables of type boolean and string. While compiling the above schema with avro maven, I am getting the following error:

org.apache.avro:avro-maven-plugin:1.10.0: schema failed:
No type: {"name":"field3","type":["null",{"name":"field3","type":"record","fields":[{"name":"address","type":["null","string"],"default":null},{"name":"isPresent","type":["null","boolean"],"default":null}]}],"default":null}

Is there something that I am missing?

0 Answers
Related