pola-rs/polars · error
activate the 'dtype-struct' feature to handle struct data…
Error message
activate the 'dtype-struct' feature to handle struct data types
What it means
DataType::from_arrow converts an Arrow schema type to a Polars DataType. When the 'dtype-struct' cargo feature is disabled, encountering ArrowDataType::Struct panics because Polars cannot represent struct data without that feature.
Solutions
- Rebuild/choose a Polars build with the 'dtype-struct' feature enabled
- Use a prebuilt full-featured Polars wheel/package instead of a minimal build
- Flatten the struct data upstream (in Arrow) before reading
Example fix
// Cargo.toml
// before
polars = { version = "x", features = ["lazy"] }
// after
polars = { version = "x", features = ["lazy", "dtype-struct"] } Defensive patterns
Strategy: type-guard
Validate before calling
# Rust build check cfg!(feature = "dtype-struct"); // gate struct-data ingestion on this
Type guard
fn supports_structs() -> bool { cfg!(feature = "dtype-struct") } Try / catch
let dt = std::panic::catch_unwind(|| DataType::from_arrow(&arrow_dt, md));
if dt.is_err() { /* fall back to flattened schema or error out clearly */ } Prevention
- Pin feature flags matching your data's schema when building Polars from source
- Prefer official wheels with default features for nested data
- Inspect Arrow schema before ingestion in minimal builds
When it happens
Trigger: Reading Arrow/Parquet/IPC data containing a Struct column into a Polars build compiled without the 'dtype-struct' feature.
Common situations: Custom or minimal Polars builds (embedded/WASM) with trimmed feature flags encountering nested struct data at runtime.
Related errors
- activate 'dtype-array'
- 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/c91be92cbc0044b9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-core/src/datatypes/field.rs:277
);
DataType::from_categories(cats)
} else if matches!(
value_type.as_ref(),
ArrowDataType::Utf8 | ArrowDataType::LargeUtf8 | ArrowDataType::Utf8View
) {
DataType::from_categories(Categories::global())
} else {
Self::from_arrow(value_type, None)
}
},
#[cfg(feature = "dtype-struct")]
ArrowDataType::Struct(fields) => {
DataType::Struct(fields.iter().map(|fld| fld.into()).collect())
},
#[cfg(not(feature = "dtype-struct"))]
ArrowDataType::Struct(_) => {
panic!("activate the 'dtype-struct' feature to handle struct data types")
},
ArrowDataType::Extension(ext) if ext.name.as_str() == POLARS_OBJECT_EXTENSION_NAME => {
#[cfg(feature = "object")]
{
DataType::Object("object")
}
#[cfg(not(feature = "object"))]
{
panic!("activate the 'object' feature to be able to load POLARS_EXTENSION_TYPE")
}
},
#[cfg(feature = "dtype-extension")]
ArrowDataType::Extension(ext) => {
use crate::prelude::extension::get_extension_type_or_storage;
let storage = DataType::from_arrow(&ext.inner, md);
match get_extension_type_or_storage(&ext.name, &storage, ext.metadata.as_deref()) {
Some(typ) => DataType::Extension(typ, Box::new(storage)),
None => storage,View on GitHub (pinned to fe841f959e)