Example Avro schema:
[
{
"type": "record",
"name": "Type1",
"namespace": "com.example",
"fields": [
{
"name": "contains",
"type": [
"null",
"Type2"
]
}
]
},
{
"type": "record",
"name": "Type2",
"namespace": "com.example",
"fields": [
{
"name": "contains",
"type": [
"null",
"Type1"
]
}
]
}
]
Type1 is referencing Type2, and Type2 is referencing Type1.
Right now, the AvroParser fails with the following error:
org.apache.avro.SchemaParseException: Undefined name: "Type2"
at org.apache.avro.Schema.parse(Schema.java:1697)
How to properly implement this cross-referencing with Avro? Is it possible to have such types as Type1 and Type2 as root-level types in the Avro schema without the need to nest one of them into another schema declaration?
The idea is to use the root flat types structure without the need to nest the declaration of the entire type into another.