in avro/src/schema.rs [1956:1981]
fn parse_union(
&mut self,
items: &[Value],
enclosing_namespace: &Namespace,
) -> AvroResult<Schema> {
items
.iter()
.map(|v| self.parse(v, enclosing_namespace))
.collect::<Result<Vec<_>, _>>()
.and_then(|schemas| {
if schemas.is_empty() {
error!(
"Union schemas should have at least two members! \
Please enable debug logging to find out which Record schema \
declares the union with 'RUST_LOG=apache_avro::schema=debug'."
);
} else if schemas.len() == 1 {
warn!(
"Union schema with just one member! Consider dropping the union! \
Please enable debug logging to find out which Record schema \
declares the union with 'RUST_LOG=apache_avro::schema=debug'."
);
}
Ok(Schema::Union(UnionSchema::new(schemas)?))
})
}