Description
We encountered an issue where our Avro schema generated with the AvroSchema macro is not compatible with itself. That is, the can_read function fails to read the generated schema. Here's a minimal reproducible example:
use apache_avro::AvroSchema; #[derive(AvroSchema)] struct Foo { a: Vec<Bar>, b: Vec<Bar>, } #[derive(AvroSchema)] struct Bar { value: i32, } #[cfg(test)] mod tests { use super::*; #[test] fn schema_reflexivity() { let schema = Foo::get_schema(); println!("{}", &schema.canonical_form()); assert_eq!(&schema, &schema); assert!(apache_avro::schema_compatibility::SchemaCompatibility::can_read(&schema, &schema)); // this fails } }
This is with the only dependency in Cargo.toml being:
apache-avro = { version = "0.16.0", features = ["derive"] }
The automatically generated Avro schema is:
{ "name": "Foo", "type": "record", "fields": [ { "name": "a", "type": { "type": "array", "items": { "name": "Bar", "type": "record", "fields": [ { "name": "value", "type": "int" } ] } } }, { "name": "b", "type": { "type": "array", "items": "Bar" } } ] }