pola-rs/polars · error

activate feature 'dtype-struct'

Error message

activate feature 'dtype-struct'

What it means

Panic/feature gate in the python function schema inference path: handling struct-typed fields requires the dtype-struct cargo feature, which is disabled in this build. Rebuild with dtype-struct enabled or avoid struct dtypes in this UDF signature.

Source

Thrown at crates/polars-plan/src/plans/functions/schema.rs:87

                                DataType::Unknown(_) => {
                                    // pass through unknown
                                },
                                _ => {
                                    polars_bail!(
                                        SchemaMismatch: "expected struct dtype, got: `{}`", dtype
                                    );
                                },
                            }
                        } else {
                            new_schema.with_column(name.clone(), dtype.clone());
                        }
                    }

                    Ok(Cow::Owned(Arc::new(new_schema)))
                }
                #[cfg(not(feature = "dtype-struct"))]
                {
                    panic!("activate feature 'dtype-struct'")
                }
            },
            RowIndex { schema, name, .. } => Ok(Cow::Owned(row_index_schema(
                schema,
                input_schema,
                name.clone(),
            ))),
            Explode {
                schema,
                options: _,
                columns,
            } => explode_schema(schema, input_schema, columns),
            #[cfg(feature = "pivot")]
            Unpivot { schema, args } => unpivot_schema(args, schema, input_schema),
            Hint(_) => Ok(Cow::Borrowed(input_schema)),
        }
    }
}

View on GitHub (pinned to 9b5d73fd00)

Solutions

  1. Enable the `dtype-struct` cargo feature for struct support in the plan/schema layer.
  2. Flatten struct columns into separate columns if the feature cannot be enabled.
Defensive patterns

Strategy: fallback

When it happens

Trigger: This panic/expect fires when execution reaches an unguarded state described by: "activate feature 'dtype-struct'". 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 ("activate feature 'dtype-struct'"). 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@9b5d73fd00 (2026-08-19). Data as JSON: /api/errors/a7edf05cf7b190ac. Report an issue: GitHub.