pola-rs/polars · error
expected list dtype
Error message
expected list dtype
What it means
ListChunked::from_par_iter_with_dtype expects the supplied dtype to be DataType::List(_); passing any other dtype (scalar, struct, etc.) while building a list series from parallel iteration falls through to this panic. Pass a List dtype (e.g. DataType::List(Box::new(inner))) to the builder.
Source
Thrown at crates/polars-core/src/chunked_array/from_iterator_par.rs:277
Some(error) => Err(error),
None => Ok(collection),
}
}
impl FromParIterWithDtype<Option<Series>> for ListChunked {
fn from_par_iter_with_dtype<I>(iter: I, name: PlSmallStr, dtype: DataType) -> Self
where
I: IntoParallelIterator<Item = Option<Series>>,
Self: Sized,
{
let vectors = collect_into_linked_list_vec(iter);
let list_capacity: usize = get_capacity_from_par_results(&vectors);
let value_capacity = get_value_cap(&vectors);
if let DataType::List(dtype) = dtype {
materialize_list(name, &vectors, *dtype, value_capacity, list_capacity).unwrap()
} else {
panic!("expected list dtype")
}
}
}
pub trait ChunkedCollectParIterExt: ParallelIterator {
fn collect_ca_with_dtype<B: FromParIterWithDtype<Self::Item>>(
self,
name: PlSmallStr,
dtype: DataType,
) -> B
where
Self: Sized,
{
B::from_par_iter_with_dtype(self, name, dtype)
}
}
impl<I: ParallelIterator> ChunkedCollectParIterExt for I {}View on GitHub (pinned to fc24390824)
Solutions
- Ensure the series/chunk being collected has a List dtype; cast or rebuild it as a list before the parallel collect.
- Check that the iterator yields list-typed values matching the expected dtype.
Defensive patterns
Strategy: type-guard
When it happens
Trigger: This panic/expect fires when execution reaches an unguarded state described by: "expected list dtype". Typical triggers: unsupported dtype or feature-gated code path reached at runtime, invalid user input or environment variable value, calling API methods in the wrong order or on mismatched types, or data (lengths, offsets, ranges) violating the function's preconditions.
Common situations: Encountered when input data or configuration does not meet the preconditions of the throwing code path ("expected list dtype"). Common cases: missing Cargo feature flags, mismatched dtypes/lengths between arrays or series, out-of-range temporal values, malformed environment variables, or operations on unsupported/complex nested types.
AI-assisted analysis of pola-rs/polars@fc24390824 (2026-08-19).
Data as JSON: /api/errors/a85399de8851029f.
Report an issue: GitHub.