Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting schema deserialisation error : Invalid default for field

While running kafka consumer, i am getting following error:

Caused by: org.apache.kafka.common.errors.SerializationException: Error deserializing Avro message for id 13
Caused by: org.apache.avro.AvroTypeException: Invalid default for field key_id: "null" not a ["null",{"type":"string","avro.java.string":"String"}]
    at org.apache.avro.Schema.validateDefault(Schema.java:1512)
    at org.apache.avro.Schema.access$300(Schema.java:86)
    at org.apache.avro.Schema$Field.<init>(Schema.java:493

My avro schema is like this :

{ "name": "key_id", "type": [ "null", "string" ], "default": "null"},

I have tried multiple options to solve this problem, but it is still there.

like image 295
SunilS Avatar asked Mar 04 '23 17:03

SunilS


1 Answers

You need to set "default": null, as opposed to "default":"null":

{ "name": "key_id", "type": [ "null", "string" ], "default": null},
like image 84
Giorgos Myrianthous Avatar answered Apr 13 '23 05:04

Giorgos Myrianthous