Closed darmstrong1 closed 3 years ago
Hi darmstrong1,
I was wondering this myself a bit and opened a small pull request that should resolve this issue. It is a limitation of the current implementation that it tries to resolve enum default values as numbers. But let's if it's okay or the schema structure is a bit different for enum default schemas.
Thanks for raising this issue. I think we have 2 problems in the area of defalt values of enums.
The first one can be seen in your code example. Currently there is a bug that does not interprete the default value for enum types correctly.
The second one is the missing implementation of "fallback defaults" for enums that are not known to the reader (schema evolution, see the long thread of https://issues.apache.org/jira/browse/AVRO-1340 for details).
I will open a new issue for the second problem and will continue tracking the first problem in this issue.
Hi, I would like to use the default feature for enums that is described here : https://avro.apache.org/docs/current/spec.html#Enums.
I tried to use the AvroDefault annotation, giving it the String value of an enum value, but I get a NumberFormatException when I try that. I'd like to use this avro feature so that schemas that use enums can be backward compatible. It seems the only way to achieve this is to give the field a default value that is one of the enum values in case a reader is using an older version that does not know about added values for that enum.
I'm pretty new to avro4k, so maybe avro4k supports this feature in a way I don't know about.
Here is what I tried:
This is what I get:
If this feature is not supported in avro4k, do you plan to support it in the future?