{"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":"error","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/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-arrow/src/io/avro/write/serialize.rs#L478-L514","documentation":"The final catch-all arm of `new_serializer` in crates/polars-arrow/src/io/avro/write/serialize.rs is `todo!(\"{:?} -> {:?} not supported\", a, b)` — reached when no (Arrow physical type, Avro schema) pair matched. This is an explicit 'known gap': the combination is recognized but not implemented (unlike the unreachable! arms, which assert internal consistency). The companion predicate `can_serialize(dtype)` exists precisely to test support without panicking.","triggerScenarios":"Writing an Arrow array to Avro whose dtype has no serializer: Utf8View/BinaryView strings in some paths, Dictionary-encoded arrays, fixed-size lists, null-typed columns, or any primitive whose Avro schema variant doesn't pair with the physical type (e.g. Int8 array paired with an Avro long schema).","commonSituations":"Polars string columns stored as Utf8View (the modern default) being handed to the Avro writer; dictionary-encoded data read from parquet then written to Avro; schema pairs where nullability or type width differs between Arrow and the Avro schema.","solutions":["Call `can_serialize(array.dtype().to_storage())` before writing and fail fast with a clean error.","Cast unsupported dtypes to supported ones first: Utf8View -> Utf8, BinaryView -> Binary, Dictionary -> dense values, FixedSizeList -> List.","Drop or stringify genuinely unsupported columns.","Check the can_serialize match list in your polars version to see exactly which dtypes are writable."],"exampleFix":"// before\nlet ser = new_serializer(&utf8_view_array, &schema)?; // todo!(): views not supported\n\n// after\nuse polars_arrow::io::avro::write::serialize::can_serialize;\nif !can_serialize(&array.dtype().to_storage()) {\n    let array = array.to_boxed().cast(&ArrowDataType::LargeUtf8)?; // view -> utf8\n}\nlet ser = new_serializer(&array, &schema)?;","handlingStrategy":"validation","validationCode":"use polars_arrow::io::avro::write::serialize::can_serialize;\nif !can_serialize(&array.dtype().to_storage()) {\n    polars_bail!(InvalidOperation: \"avro writer does not support dtype {:?}\", array.dtype());\n}","typeGuard":"fn avro_writable(dtype: &ArrowDataType) -> bool {\n    polars_arrow::io::avro::write::serialize::can_serialize(&dtype.to_storage())\n}","tryCatchPattern":"let ser = std::panic::catch_unwind(|| new_serializer(&array, &schema))\n    .map_err(|_| polars_err!(InvalidOperation: \"arrow->avro unsupported for {:?} -> {:?}\", array.dtype(), schema))?;","preventionTips":["Call can_serialize on every column dtype before starting an Avro write.","Pre-cast view strings (Utf8View/BinaryView) and dictionary arrays to Utf8/Binary and dense values.","Cache the supported-type list for your polars version in CI checks."],"tags":["rust","polars","arrow","avro","unsupported-type","dtype","panic"],"backgroundTag":"avro-unsupported-type-conversion","analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}