pola-rs/polars · error
activate 'dtype-array'
Error message
activate 'dtype-array'
What it means
This panic fires from the `Box<dyn Array>` FromIterator-with-dtype impl for list-like arrays when the crate was compiled without the `dtype-array` Cargo feature. Collecting into a FixedSizeListArray (the ArrayCollectNamespace path that materializes nested list physical types) is only implemented when that feature is active, so the un-supported build deliberately panics instead of silently producing wrong results.
Solutions
- Enable the `dtype-array` feature on the polars/polars-arrow dependency in Cargo.toml (e.g. `polars = { version = "...", features = ["dtype-array"] }`).
- Run `cargo tree -i polars-arrow` to confirm which feature graph is being built and ensure no `default-features = false` setting strips the feature.
- If you control the call site, avoid the FixedSizeList collect path (or gate it behind `#[cfg(feature = "dtype-array")]`) so the panic branch is unreachable.
- Upgrade polars to a version where the needed collect impl is available under your feature set.
Example fix
// before (Cargo.toml)
polars = { version = "0.40", default-features = false, features = ["lazy"] }
// after
polars = { version = "0.40", default-features = false, features = ["lazy", "dtype-array"] } Defensive patterns
Strategy: validation
Validate before calling
// Cargo.toml check (build-time guard)
#[cfg(not(feature = "dtype-array"))]
compile_error!("this code requires the polars 'dtype-array' feature");
// runtime guard before collect:
assert!(matches!(dtype.to_storage(), ArrowDataType::FixedSizeList(_, _)) && cfg!(feature = "dtype-array")); Prevention
- Declare all polars features you depend on explicitly in Cargo.toml
- Use `cargo tree -e features` to audit which features reach polars-arrow
- Pin feature sets in CI to catch feature-unification regressions
When it happens
Trigger: Calling an API that collects an iterator into an array with an explicit nested dtype (e.g. `arr.collect_arr_with_dtype` targeting a FixedSizeList/FixedShapeList type) on a polars-arrow build lacking the `dtype-array` feature.
Common situations: Users enable `lazy` or `dtype-array`-dependent Polars features in their own crates but polars-arrow is pulled in transitively with default features; a Cargo feature-unification change or a minimal-features build drops the flag and a code path that previously worked starts panicking at runtime.
Related errors
- activate the 'dtype-struct' feature to handle struct data…
- activate dtype-categorical to convert dictionary arrays
- activate ' ' feature
- activate feature dtype-duration
- activate 'propagate_nans' feature
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/a987d1c89280dfe2.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-arrow/src/array/static_array_collect.rs:860
{
let ArrowDataType::FixedSizeList(_, width) = &dtype else {
panic!("FixedSizeListArray::arr_from_iter_with_dtype called with non-Array dtype");
};
let iter_values: Vec<_> = iter.into_iter().collect();
let mut builder = AnonymousFixedSizeListArrayBuilder::new(iter_values.len(), *width);
for arr in iter_values {
match arr {
Some(a) => builder.push(a.into_boxed_array()),
None => builder.push_null(),
}
}
let inner = dtype
.inner_dtype()
.expect("expected nested type in ListArray collect");
builder.finish(&inner.underlying_physical_type()).unwrap()
}
#[cfg(not(feature = "dtype-array"))]
panic!("activate 'dtype-array'")
}
fn try_arr_from_iter_with_dtype<
E,
I: IntoIterator<Item = Result<Option<Box<dyn Array>>, E>>,
>(
dtype: ArrowDataType,
iter: I,
) -> Result<Self, E> {
let iter_values = iter.into_iter().collect::<Result<Vec<_>, E>>()?;
Ok(Self::arr_from_iter_with_dtype(dtype, iter_values))
}
}
impl ArrayFromIter<Option<()>> for StructArray {
fn arr_from_iter<I: IntoIterator<Item = Option<()>>>(_iter: I) -> Self {
no_call_const!()
}View on GitHub (pinned to fe841f959e)