Open kitsuneninetails opened 3 years ago
Just FYI this should match your schema:
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Updated {
pub id: String,
}
impl Default for Updated {
fn default() -> Updated {
Updated {
id: String::default(),
}
}
}
#[derive(Debug, PartialEq, Clone, serde::Deserialize, serde::Serialize)]
#[serde(default)]
pub struct Test {
pub event: Option<Updated>,
}
impl Default for Test {
fn default() -> Test {
Test {
event: None,
}
}
}
As far as I know, the following schema is perfectly acceptable in avro:
But, the fact that I have a union where one type is not a primitive type (i.e. a record), seems to return "unsupported Union" errors when trying to deserialize (it builds the schema just fine, apparently).
Looking at the code, it indeed has:
in the deserialize code (deserialize_any).
Why isn't this supported? Wouldn't it be easy to just have the Record type run a recursive parser on the body underneath?
Edit:
I found some code in deserialize struct that has:
Is this saying that I have to deserialize unions with records straight into a struct (or, I assume, an Option to handle unions with "null"?)? So, basically, skip the enum in the deserialized data structure and go straight to the one variant that matches the struct?