Say you have this AVDL as a simplified example:
@namespace("example.avro")
protocol User {
record Man {
int age;
}
record Woman {
int age;
}
record User {
union {
Man,
Woman
} user_info;
}
}
in python you are not able to properly serialize objects stating the type because this syntax is not allowed:
{"user_info": {"Woman": {"age": 18}}}
and the only object that gets serialized is
{"user_info": {"age": 18}}
losing all the type information and the DatumWriter
picking usually the first record that matches the set of fields, in this case a Man
.
The above problem works perfectly well when using the Java API.
So, what am I doing wrong here? Is it possible that serialization and deserialization is not idempotent in Python's Avro implementation?