pola-rs/polars · error
The schema declaration does not match the deserialization
Error message
The schema declaration does not match the deserialization
What it means
new_serializer matches each Arrow PhysicalType against the expected AvroSchema variant (e.g. List vs AvroSchema::Array). The panic fires when the pair of Arrow physical type and Avro schema declaration is inconsistent — the data was deserialized against a different schema than the one supplied for serialization.
Solutions
- Ensure the Avro schema passed to the serializer is the same one used when the Arrow data was created/deserialized
- Check that list/large-list and union schema variants line up with the actual array PhysicalType
- Regenerate the writer schema from the same source as the reader schema
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/polars-arrow/src/io/avro/write/serialize.rs:473 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/7048a9ecbd03e5fb.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-arrow/src/io/avro/write/serialize.rs:473
} else {
buf.push(IS_NULL);
}
},
vec![],
))
},
(PhysicalType::List, AvroSchema::Array(schema)) => {
list_required::<i32>(array.as_any().downcast_ref().unwrap(), schema.as_ref())
},
(PhysicalType::LargeList, AvroSchema::Array(schema)) => {
list_required::<i64>(array.as_any().downcast_ref().unwrap(), schema.as_ref())
},
(PhysicalType::List, AvroSchema::Union(inner)) => {
let schema = if let AvroSchema::Array(schema) = &inner[1] {
schema.as_ref()
} else {
unreachable!("The schema declaration does not match the deserialization")
};
list_optional::<i32>(array.as_any().downcast_ref().unwrap(), schema)
},
(PhysicalType::LargeList, AvroSchema::Union(inner)) => {
let schema = if let AvroSchema::Array(schema) = &inner[1] {
schema.as_ref()
} else {
unreachable!("The schema declaration does not match the deserialization")
};
list_optional::<i64>(array.as_any().downcast_ref().unwrap(), schema)
},
(PhysicalType::Struct, AvroSchema::Record(inner)) => {
struct_required(array.as_any().downcast_ref().unwrap(), inner)
},
(PhysicalType::Struct, AvroSchema::Union(inner)) => {
let inner = if let AvroSchema::Record(inner) = &inner[1] {
inner
} else {View on GitHub (pinned to fe841f959e)