{"record":{"id":"965799750278369d","repo":"pola-rs/polars","slug":"not-supported","errorCode":null,"errorMessage":"{:?} -> {:?} not supported","messagePattern":"(.+?) -> (.+?) not supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"crates/polars-arrow/src/io/avro/write/serialize.rs","lineNumber":496,"sourceCode":"            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 {\n                unreachable!(\"The schema declaration does not match the deserialization\")\n            };\n            struct_optional(array.as_any().downcast_ref().unwrap(), inner)\n        },\n        (a, b) => todo!(\"{:?} -> {:?} not supported\", a, b),\n    }\n}\n\n/// Whether [`new_serializer`] supports `dtype`.\npub fn can_serialize(dtype: &ArrowDataType) -> bool {\n    use ArrowDataType::*;\n    match dtype.to_storage() {\n        List(inner) => return can_serialize(&inner.dtype),\n        LargeList(inner) => return can_serialize(&inner.dtype),\n        Struct(inner) => return inner.iter().all(|inner| can_serialize(&inner.dtype)),\n        _ => {},\n    };\n\n    matches!(\n        dtype,\n        Boolean\n            | Int32\n            | Int64","sourceCodeStart":478,"sourceCodeEnd":514,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-arrow/src/io/avro/write/serialize.rs#L478-L514","documentation":"The Avro writer's `new_serializer` dispatches on pairs of (Arrow data type, Avro schema type). When it receives a combination it has no arm for, it hits a `todo!()` panic with this message, printing the unsupported Arrow type and Avro type via `{:?}`. It is an unimplemented-feature guard, not a recoverable error: the library simply cannot yet serialize that dtype/schema pair to Avro.","triggerScenarios":"Calling the Avro writer (`avro write` path) on an Arrow array whose `ArrowDataType` does not pair with a matching Avro schema type — e.g. a non-nullable Arrow type arriving at `struct_optional`/`list_optional`, or types like Decimal, Duration, or Dictionary that have no serializer arm. Preceded by `can_serialize` returning true or the caller skipping that gate.","commonSituations":"Users converting Arrow tables with exotic dtypes (dictionaries, decimals, extension types) to Avro; downstream code (e.g. polars `to_avro`) hitting a dtype the Avro encoder never implemented; schema-mismatch after version changes where the Avro schema declaration no longer matches the Arrow schema so the unreachable!/todo! arm is reached.","solutions":["Identify the printed dtype/schema pair and cast the offending column to a supported Arrow type (e.g. cast Dictionary/Decimal to primitive types) before writing to Avro.","Filter or drop unsupported columns before calling the Avro writer.","Check `can_serialize(dtype)` for every column before writing and route unsupported ones to another sink (Parquet/IPC).","If the schema declaration mismatch caused the bad pair, regenerate/fix the Avro schema so it matches the Arrow schema.","File or upvote an upstream issue to implement the missing serializer arm."],"exampleFix":"// before\ndf.write_avro(\"out.avro\").unwrap(); // panics on Dictionary(Utf8) column\n\n// after\nlet df = df.with_columns([\n    col(\"dict_col\").cast(DataType::String),\n]).unwrap();\ndf.write_avro(\"out.avro\").unwrap();","handlingStrategy":"validation","validationCode":"// rust\nuse polars_arrow::datatypes::ArrowDataType;\nuse polars_arrow::io::avro::write::can_serialize;\n\nfn assert_avro_writable(schema: &[ArrowField]) -> Result<(), String> {\n    for f in schema {\n        if !can_serialize(&f.dtype) {\n            return Err(format!(\"column '{}' has dtype {:?} not serializable to Avro; cast or drop it first\", f.name, f.dtype));\n        }\n    }\n    Ok(())\n}\n// call before invoking the Avro writer","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check can_serialize(dtype) for every column before any Avro write.","Cast Dictionary/Decimal/Duration columns to supported primitives before Avro export.","Keep the Arrow schema and Avro schema in sync and regenerate both together.","Pin polars-arrow versions and check release notes for newly supported Avro dtypes."],"tags":["avro","arrow","unsupported-dtype","serialization","panic"],"backgroundTag":"unsupported-dtype","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"}