1

I am processing 2 different avro files:

avroConsumer:

{"namespace": "autoGenerated.avro",
  "type": "record",
  "name": "UserConsumer",
  "fields": [
    {"name": "Name", "type": "string"},
    {"name": "Surname", "type":["null","string"],"default": null},
    {"name": "favorite_number",  "type": ["long", "null"]},
    {"name": "favorite_color", "type": ["string", "null"]}
  ]
}

avroProducer:

{"namespace": "autoGenerated.avro",
  "type": "record",
  "name": "UserProducer",
  "fields": [
    {"name": "name", "type": "string"},
    {"name": "favorite_number",  "type": ["int", "null"]},
    {"name": "favorite_color", "type": ["string", "null"]}
  ]
}

On compiling procedure a deserialization error occurs but I thought that defining the "default" attribute in the consumer should make it work correctly.
Reference: http://avro.apache.org/docs/current/spec.html#Schema+Resolution

if the reader's record schema has a field that contains a default value, and writer's schema does not have a field with the same name, then the reader should use the default value from its field.

Do you have some ideas? Can I define a different consumer avro file than the producer avro file?

mazaneicha
  • 8,794
  • 4
  • 33
  • 52
SteVizzo
  • 29
  • 5
  • The consumer schema defines a field named `Name` but the producer schema defines a field named `name`. Field names are case-sensitive. From Avro's perspective, it appears a field was deleted and another field was added. – Chin Huang Jul 27 '18 at 14:39
  • Ok you are right but my deserialization errors occcur not for the different Capitalized attribute, it should be compatible because is a string. – SteVizzo Jul 30 '18 at 15:45

0 Answers0