-
-
Notifications
You must be signed in to change notification settings - Fork 36
Inter Schema references
Sergey Fedorov edited this page Jan 19, 2020
·
1 revision
It allows you to reference one schema from another without a need for duplication.
This is similar to avro_turf Inter-Schema references,
but unlike avro_turf
after the type references got resolved and embedded
to the main schema (compiled) all local type names will be de-canonicalized.
For example, you have a Messenger
schema which contains the references to
the Message
schema:
priv/schemas/io/confluent/Messenger.avsc
{
"type": "record",
"name": "Messenger",
"namespace": "io.confluent",
"fields": [
{
"name": "inbox",
"type": {
"type": "array",
"items": "io.confluent.Message"
}
},
{
"name": "archive",
"type": {
"type": "array",
"items": "io.confluent.Message"
}
}
]
}
priv/schemas/io/confluent/Message.avsc
{
"type": "record",
"name": "Message",
"namespace": "io.confluent",
"fields": [
{
"name": "text",
"type": "string"
}
]
}
Final compiled schema which will be stored and registered in the Confluent Schema Registry will look like this:
{
"type": "record",
"name": "Messenger",
"namespace": "io.confluent",
"fields": [
{
"name": "inbox",
"type": {
"type": "array",
"items": {
"type": "record",
"name": "Message",
"fields": [
{
"name": "text",
"type": "string"
}
]
}
}
},
{
"name": "archive",
"type": {
"type": "array",
"items": "Message"
}
}
]
}
💢 In case of avro_turf
field archive
will keep its canonical items
type reference io.confluent.Message
instead of local reference Message
.