{"record":{"id":"7048a9ecbd03e5fb","repo":"pola-rs/polars","slug":"the-schema-declaration-does-not-match-the-deserial","errorCode":null,"errorMessage":"The schema declaration does not match the deserialization","messagePattern":"The schema declaration does not match the deserialization","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-arrow/src/io/avro/write/serialize.rs","lineNumber":473,"sourceCode":"                    } else {\n                        buf.push(IS_NULL);\n                    }\n                },\n                vec![],\n            ))\n        },\n\n        (PhysicalType::List, AvroSchema::Array(schema)) => {\n            list_required::<i32>(array.as_any().downcast_ref().unwrap(), schema.as_ref())\n        },\n        (PhysicalType::LargeList, AvroSchema::Array(schema)) => {\n            list_required::<i64>(array.as_any().downcast_ref().unwrap(), schema.as_ref())\n        },\n        (PhysicalType::List, AvroSchema::Union(inner)) => {\n            let schema = if let AvroSchema::Array(schema) = &inner[1] {\n                schema.as_ref()\n            } else {\n                unreachable!(\"The schema declaration does not match the deserialization\")\n            };\n            list_optional::<i32>(array.as_any().downcast_ref().unwrap(), schema)\n        },\n        (PhysicalType::LargeList, AvroSchema::Union(inner)) => {\n            let schema = if let AvroSchema::Array(schema) = &inner[1] {\n                schema.as_ref()\n            } else {\n                unreachable!(\"The schema declaration does not match the deserialization\")\n            };\n            list_optional::<i64>(array.as_any().downcast_ref().unwrap(), schema)\n        },\n        (PhysicalType::Struct, AvroSchema::Record(inner)) => {\n            struct_required(array.as_any().downcast_ref().unwrap(), inner)\n        },\n        (PhysicalType::Struct, AvroSchema::Union(inner)) => {\n            let inner = if let AvroSchema::Record(inner) = &inner[1] {\n                inner\n            } else {","sourceCodeStart":455,"sourceCodeEnd":491,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/io/avro/write/serialize.rs#L455-L491","documentation":"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.","triggerScenarios":"Thrown at crates/polars-arrow/src/io/avro/write/serialize.rs:473 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}