I am trying to use Avro Schema with Kafka.
My Question is suppose I have a schema with 2 fields and have mentioned defaults in both of them :
“fields”: [
{
“name”: “lastName”,
“type”: “string”,
“default” : “garg”
},
{
“name”: “firstName”,
“type”: “string”,
“default” : “harsh”
}
]
Now,If i try to produce data with only one field (“lastName”) I am expecting that the producer will take the default for the other which is “harsh” in this case but it takes null and throws error :
Cannot invoke “Object.getClass()” because “datum” is null
How to fix this as if i have 2 versions of producers one with 1 field and other with 2 fields
then the first one will never able to produce data with default value i want.
shivang garg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.