You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
null deserializes to None, but int/long yield a "not an enum" error rather than Some(UnionIntLong::Int/Long(…)).
I understand why this happens:
deserialize_enum is called on the avro-rs Deserializer
The current Value token is Int or Long, not Enum, thus the error
I tried manually implementing Deserialize, but there's no way (afaik) to tell what Value the current token is. The best I can do is call deserialize_any, which only works for int/long/float/double/boolean types, not strings.
I opened an rsgen-avro issue about this and the author suggested an EnumUnionDeserializer in avro-rs that can deserialize enum variants with names like Int or Long properly. It's not ideal because avro-rs would have special rules based on the naming of enum variants, but it's the only way I've found that can deserialize these types correctly (and the only way to deserialize Avro date to a Date variant instead of Int, since they're both i32 values).
I have a reproduction of my original issue if that's of any help in illustrating what I'm talking about. I'm curious if this idea has any merit or if it's not something avro-rs should implement. Thanks for your time!
The text was updated successfully, but these errors were encountered:
I saw the announcement regarding Apache taking ownership of this repo, so let me know if I should move this to their bug tracker!
I'm using
rsgen-avro
to generate types for my Avro schemas, which for unions like["null", "int", "long"]
creates this in Rust:null
deserializes toNone
, butint
/long
yield a "not an enum" error rather thanSome(UnionIntLong::Int/Long(…))
.I understand why this happens:
deserialize_enum
is called on the avro-rsDeserializer
Value
token isInt
orLong
, notEnum
, thus the errorI tried manually implementing
Deserialize
, but there's no way (afaik) to tell whatValue
the current token is. The best I can do is calldeserialize_any
, which only works for int/long/float/double/boolean types, not strings.I opened an rsgen-avro issue about this and the author suggested an
EnumUnionDeserializer
in avro-rs that can deserialize enum variants with names likeInt
orLong
properly. It's not ideal because avro-rs would have special rules based on the naming of enum variants, but it's the only way I've found that can deserialize these types correctly (and the only way to deserialize Avrodate
to aDate
variant instead ofInt
, since they're both i32 values).I have a reproduction of my original issue if that's of any help in illustrating what I'm talking about. I'm curious if this idea has any merit or if it's not something avro-rs should implement. Thanks for your time!
The text was updated successfully, but these errors were encountered: