{"record":{"id":"d1c1a50f2114dd18","repo":"pola-rs/polars","slug":"multiple-nested-objects-not-yet-supported","errorCode":null,"errorMessage":"multiple nested objects not yet supported","messagePattern":"multiple nested objects not yet supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/object/extension/drop.rs","lineNumber":16,"sourceCode":"use crate::chunked_array::object::extension::PolarsExtension;\nuse crate::prelude::*;\n\n/// This will dereference a raw ptr when dropping the [`PolarsExtension`], make sure that it's valid.\npub(crate) unsafe fn drop_list(ca: &ListChunked) {\n    let mut inner = ca.inner_dtype();\n    let mut nested_count = 0;\n\n    while let Some(a) = inner.inner_dtype() {\n        nested_count += 1;\n        inner = a;\n    }\n\n    if matches!(inner, DataType::Object(_)) {\n        if nested_count != 0 {\n            panic!(\"multiple nested objects not yet supported\")\n        }\n        for lst_arr in &ca.chunks {\n            if let ArrowDataType::LargeList(fld) = lst_arr.dtype() {\n                let dtype = fld.dtype();\n\n                assert!(matches!(dtype, ArrowDataType::Extension(_)));\n\n                // recreate the polars extension so that the content is dropped\n                let arr = lst_arr.as_any().downcast_ref::<LargeListArray>().unwrap();\n\n                let values = arr.values();\n                drop_object_array(values.as_ref())\n            }\n        }\n    }\n}\n\npub(crate) unsafe fn drop_object_array(values: &dyn Array) {","sourceCodeStart":1,"sourceCodeEnd":34,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/chunked_array/object/extension/drop.rs#L1-L34","documentation":"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.","triggerScenarios":"Calling Series::drop (via drop_slow / drop_list) on a column of type List(List(Object)) or another nested combination ending in Object.","commonSituations":"Frames holding custom Rust object columns wrapped in multiple levels of lists, then dropping that column from a DataFrame.","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."],"exampleFix":"// before\nlet out = df.drop(\"obj_col\")?; // obj_col: List(List(Object)) -> panic\n// after\nlet flat = df.explode(\"obj_col\")?.explode(\"obj_col\")?; // reduce nesting first\nlet out = flat.drop(\"obj_col\")?;","handlingStrategy":"validation","validationCode":"// Guard: object columns must be at most single-level List\nfn drop_ok(dtype: &DataType) -> bool {\n    match dtype {\n        DataType::List(inner) => !matches!(inner.as_ref(), DataType::List(_) | DataType::Object(_)),\n        DataType::Object(_) => false,\n        _ => true,\n    }\n}","typeGuard":"fn is_single_list_object(dtype: &DataType) -> bool {\n    matches!(dtype, DataType::List(inner) if matches!(inner.as_ref(), DataType::Object(_)))\n}","tryCatchPattern":null,"preventionTips":["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."],"tags":["rust","polars","object-dtype","nested-data"],"backgroundTag":"unsupported-operation","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}