pola-rs/polars · error

activate 'dtype-array'

Error message

activate 'dtype-array'

What it means

This panic is a deliberate guard: FixedSizeListArray::arr_from_iter_with_dtype still compiles when polars-arrow is built without the dtype-array feature, but the fixed-width machinery behind it is feature-gated, so the cfg(not(feature = "dtype-array")) body just panics with 'activate 'dtype-array''.

Source

Thrown at crates/polars-arrow/src/array/static_array_collect.rs:821

        #[cfg(feature = "dtype-array")]
        {
            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 {
                builder.push(arr.into_boxed_array());
            }
            let inner = dtype
                .inner_dtype()
                .expect("expected nested type in ListArray collect");
            builder
                .finish(Some(&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<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 ArrayFromIterDtype<Option<Box<dyn Array>>> for FixedSizeListArray {
    #[allow(unused_variables)]
    fn arr_from_iter_with_dtype<I: IntoIterator<Item = Option<Box<dyn Array>>>>(
        dtype: ArrowDataType,
        iter: I,
    ) -> Self {
        #[cfg(feature = "dtype-array")]

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Add features = ["dtype-array"] to the polars-arrow (or polars) dependency in Cargo.toml
  2. Make sure the crate that actually calls the collect API — not merely a transitive one — enables the feature
  3. Verify the resolved build with cargo tree -e features -i polars-arrow | grep dtype-array

Example fix

# before
polars-arrow = "0.5"

# after
polars-arrow = { version = "0.5", features = ["dtype-array"] }
Defensive patterns

Strategy: validation

Validate before calling

# Cargo.toml — the crate calling the API must enable the feature:
[dependencies]
polars-arrow = { version = "0.5", features = ["dtype-array"] }

# verify the resolved build actually carries it:
# cargo tree -e features -i polars-arrow | grep dtype-array

Prevention

When it happens

Trigger: Calling any collect-into-FixedSizeListArray path (arr_from_iter_with_dtype / try_arr_from_iter_with_dtype) in a build of polars-arrow whose resolved Cargo features do not include dtype-array — e.g. depending on polars-arrow with default-features = false.

Common situations: A new crate adds polars-arrow with default features only; Cargo feature unification resolves polars-arrow without dtype-array because another dependency requested a reduced build; a polars upgrade split the feature out and the pin no longer enables it.

Related errors


AI-assisted analysis of pola-rs/polars@9b5d73fd00 (2026-08-19). Data as JSON: /api/errors/a987d1c89280dfe2. Report an issue: GitHub.