Closed trdw closed 10 months ago
Hello, sorry for the delay, I'll take a lot at it to see if it is not changing some other behavior. Thanks for the PR 🚀
AFAIK, without your PR, we are able to decode an old schema written with an alias while the kotlin data class uses the real field name (not alias).
What is not working is when you read a new schema where the kotlin data class is using an alias for its field name instead of the real field name. That's because apache avro library "normalize" the field name, and whatever the alias name or the real name, it creates a GenericRecord using field's real name (that is totally normal).
I don't see any particular issue, I approve it. @thake it's ok for you also ?
Side note: We should cache somewhere with a map like Map<alias, real name>
to prevent useless aliases iterations. Let's plan it for v2
@thake
Problem: We want to read some data using Avro evolution mechanism for field renaming. Current behavior does not account for AvroAlias annotation.
Proposed solution: fieldValue() function iterates through list of possible field names, starting with the resolvedFieldName. For each attempt, if record contains the field name, return the value returned from record.get(...), else continue.
Closes #170