Getting schema deserialisation error : Invalid default for field
Asked Answered
K

1

7

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.

Kirkpatrick answered 18/7, 2019 at 12:36 Comment(0)
C
13

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

{ "name": "key_id", "type": [ "null", "string" ], "default": null},
Chavers answered 18/7, 2019 at 13:42 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.