in avro/src/schema_compatibility.rs [242:268]
fn match_union_schemas(
&mut self,
writers_schema: &Schema,
readers_schema: &Schema,
) -> Result<(), CompatibilityError> {
if let Schema::Union(u) = writers_schema {
if u.schemas
.iter()
.all(|schema| self.full_match_schemas(schema, readers_schema).is_ok())
{
return Ok(());
} else {
return Err(CompatibilityError::MissingUnionElements);
}
} else if let Schema::Union(u) = readers_schema {
// This check is needed because the writer_schema can be not union
// but the type can be contain in the union of the reader schema
// e.g. writer_schema is string and reader_schema is [string, int]
if u.schemas
.iter()
.any(|schema| self.full_match_schemas(writers_schema, schema).is_ok())
{
return Ok(());
}
}
Err(CompatibilityError::MissingUnionElements)
}