pola-rs/polars · error
multiple nested objects not yet supported
Error message
multiple nested objects not yet supported
What it means
When dropping object columns, Polars unwraps nested list types to find the innermost element type. If the innermost dtype is an Object but it is wrapped in nested lists (nested_count != 0), the operation is unsupported and panics — only a single-level List(Object) is handled.
Solutions
- Flatten the nested lists before the frame is used, so the object column is at a single List level.
- Store custom objects at top level (Object column) rather than nested inside lists.
- Rebuild the DataFrame without the problematic column instead of calling drop on it.
- If you own the pipeline, avoid nesting Object dtypes; keep only one list level.
Example fix
// before
let out = df.drop("obj_col")?; // obj_col: List(List(Object)) -> panic
// after
let flat = df.explode("obj_col")?.explode("obj_col")?; // reduce nesting first
let out = flat.drop("obj_col")?; Defensive patterns
Strategy: validation
Validate before calling
// Guard: object columns must be at most single-level List
fn drop_ok(dtype: &DataType) -> bool {
match dtype {
DataType::List(inner) => !matches!(inner.as_ref(), DataType::List(_) | DataType::Object(_)),
DataType::Object(_) => false,
_ => true,
}
} Type guard
fn is_single_list_object(dtype: &DataType) -> bool {
matches!(dtype, DataType::List(inner) if matches!(inner.as_ref(), DataType::Object(_)))
} Prevention
- Never nest Object-typed columns inside multiple list levels.
- Flatten nested lists before storing custom objects.
- Prefer storing object payloads in a side table keyed by index instead of nested lists.
- Check dtype nesting depth before DataFrame::drop on object columns.
When it happens
Trigger: Calling Series::drop (via drop_slow / drop_list) on a column of type List(List(Object)) or another nested combination ending in Object.
Common situations: Frames holding custom Rust object columns wrapped in multiple levels of lists, then dropping that column from a DataFrame.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- creating extension types not allowed - try setting the…
- horizontal_flatten not supported for data type
- ordering for Object dtype is not supported
- `unique` operation not supported for dtype
- {0}
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/d1c1a50f2114dd18.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-core/src/chunked_array/object/extension/drop.rs:16
use crate::chunked_array::object::extension::PolarsExtension;
use crate::prelude::*;
/// This will dereference a raw ptr when dropping the [`PolarsExtension`], make sure that it's valid.
pub(crate) unsafe fn drop_list(ca: &ListChunked) {
let mut inner = ca.inner_dtype();
let mut nested_count = 0;
while let Some(a) = inner.inner_dtype() {
nested_count += 1;
inner = a;
}
if matches!(inner, DataType::Object(_)) {
if nested_count != 0 {
panic!("multiple nested objects not yet supported")
}
for lst_arr in &ca.chunks {
if let ArrowDataType::LargeList(fld) = lst_arr.dtype() {
let dtype = fld.dtype();
assert!(matches!(dtype, ArrowDataType::Extension(_)));
// recreate the polars extension so that the content is dropped
let arr = lst_arr.as_any().downcast_ref::<LargeListArray>().unwrap();
let values = arr.values();
drop_object_array(values.as_ref())
}
}
}
}
pub(crate) unsafe fn drop_object_array(values: &dyn Array) {View on GitHub (pinned to fe841f959e)