I have two versions of the same schema where a breaking change has been made. Is there a way to inject code into Avro so that it knows how to deal with this breaking change?
Example:
Schema 1 – the keys are a list of strings
<code>{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": "string"
}
}
]
}
</code>
<code>{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": "string"
}
}
]
}
</code>
{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": "string"
}
}
]
}
Schema 2 – the keys are their own distinct record
<code>{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": {
"type":"record",
"name":"Key",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
}
]
}
}
}
]
}
</code>
<code>{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": {
"type":"record",
"name":"Key",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
}
]
}
}
}
]
}
</code>
{
"type":"record",
"name":"Item",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
},
{
"name":"keys",
"type": {
"type": "array",
"items": {
"type":"record",
"name":"Key",
"namespace":"com.test",
"fields":[
{
"name":"id",
"type":"string"
}
]
}
}
}
]
}
I would like to inject some custom code which converts String into Key objects, and vice-versa.