I have the following schemas:
{
"namespace": "org.wcn",
"type": "record",
"name": "Detail",
"fields": [
{
"name": "quantity",
"type": "int"
},
{
"name": "total",
"type": "float"
}
]
}
and:
{
"namespace": "org.wcn",
"type": "record",
"doc": "This Schema describes about Order",
"name": "Order",
"fields": [
{
"name": "order_id",
"type": "long"
},
{
"name": "customer_id",
"type": "long"
},
{
"name": "total",
"type": "float"
},
{
"name": "detail",
"type": "org.wcn.Detail"
}
]
}
These schemas compile and work in code locally, however:
I can upload the first one to schema registry no problem. The second one gets the error:
ERROR Could not parse Avro schema (io.confluent.kafka.schemaregistry.avro.AvroSchemaProvider)
org.apache.avro.SchemaParseException: "org.wcn.Detail" is not a defined name. The type of the "detail" field must be a defined name or a {"type": ...} expression.
This is thrown by the schema registry.
If I reconfigure the schema to be “all in one”:
{
"namespace": "org.wcn",
"type": "record",
"doc": "This Schema describes about Order",
"name": "OrderComplete",
"fields": [
{
"name": "order_id",
"type": "long"
},
{
"name": "customer_id",
"type": "long"
},
{
"name": "total",
"type": "float"
},
{
"name": "detail",
"type": {
"namespace": "org.wcn",
"type": "record",
"name": "Detail",
"fields": [
{
"name": "quantity",
"type": "int"
},
{
"name": "total",
"type": "float"
}
]
}
}
]
}
It will upload with no problems.
However this doesn’t sound like the way schema registry is intended to be used. I thought it would dereference schemas as needed so long as they were previously uploaded.
Your thoughts will be appreciated.
wcn