pola-rs/polars · critical
-> not supported
Error message
{:?} -> {:?} not supported What it means
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.
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.
Example fix
// before
df.write_avro("out.avro").unwrap(); // panics on Dictionary(Utf8) column
// after
let df = df.with_columns([
col("dict_col").cast(DataType::String),
]).unwrap();
df.write_avro("out.avro").unwrap(); Defensive patterns
Strategy: validation
Validate before calling
// rust
use polars_arrow::datatypes::ArrowDataType;
use polars_arrow::io::avro::write::can_serialize;
fn assert_avro_writable(schema: &[ArrowField]) -> Result<(), String> {
for f in schema {
if !can_serialize(&f.dtype) {
return Err(format!("column '{}' has dtype {:?} not serializable to Avro; cast or drop it first", f.name, f.dtype));
}
}
Ok(())
}
// call before invoking the Avro writer Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Could not 'unwrap_optional'. 'ZipValidity' iterator has no…
- Could not 'unwrap_required'. 'ZipValidity' iterator has…
- dtype not supported
- failed to encode spill file for
- failed to serialize schema hashes file
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/965799750278369d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-arrow/src/io/avro/write/serialize.rs:496
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 {
unreachable!("The schema declaration does not match the deserialization")
};
struct_optional(array.as_any().downcast_ref().unwrap(), inner)
},
(a, b) => todo!("{:?} -> {:?} not supported", a, b),
}
}
/// Whether [`new_serializer`] supports `dtype`.
pub fn can_serialize(dtype: &ArrowDataType) -> bool {
use ArrowDataType::*;
match dtype.to_storage() {
List(inner) => return can_serialize(&inner.dtype),
LargeList(inner) => return can_serialize(&inner.dtype),
Struct(inner) => return inner.iter().all(|inner| can_serialize(&inner.dtype)),
_ => {},
};
matches!(
dtype,
Boolean
| Int32
| Int64View on GitHub (pinned to fe841f959e)