I have an application in which am using Kafka with schema registry to produce messages.I have a topic called plans , in which there are fields like id,name,type etc.,. Now there are deiffrent fields which are having a value only for certain type of plans. Example am having fields such as ‘time’ ,`duration’ for only one type of plan . And there are different fields which are common for 2 or 3 types of plans . The current AVRO schema is linear , so if i have to add a new type of plan , again i will add 2 or 3 fields which are having a value directly in to schema . This is causing the fields to grow horizontally at consumer end . Is there any way using which i can come up with a scalable AVRO schema which may of some nested type , so that the fields won’t grow horizontally and which is not complex to use at consumer end also .
`
{
"type": "record",
"name": "Plan",
"namespace": "com.example",
"fields": [
{"name": "id", "type": "string"},
{"name": "name", "type": "string"},
{"name": "description", "type": ["null", "string"], "default": null},
{"name": "planType", "type": "string"},
{"name": "specificFieldA1", "type": ["null", "string"], "default": null},
{"name": "specificFieldA2", "type": ["null", "int"], "default": null},
{"name": "specificFieldB1", "type": ["null", "string"], "default": null},
{"name": "specificFieldB2", "type": ["null", "double"], "default": null},
{"name": "specificFieldC1", "type": ["null", "string"], "default": null},
{"name": "specificFieldC2", "type": ["null", "boolean"], "default": null}
]
}`
Surya Varchasvi N is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.