{"record":{"id":"fd49c4d687793339","repo":"pola-rs/polars","slug":"horizontal-flatten-not-supported-for-data-type","errorCode":null,"errorMessage":"horizontal_flatten not supported for data type {:?}","messagePattern":"horizontal_flatten not supported for data type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-compute/src/horizontal_flatten/mod.rs","lineNumber":125,"sourceCode":"                        .downcast_ref::<BinaryViewArray>()\n                        .unwrap()\n                        .clone()\n                })\n                .collect::<Vec<_>>(),\n            widths,\n            output_height,\n            dtype,\n        )),\n        Utf8View => Box::new(horizontal_flatten_unchecked_impl_generic(\n            &arrays\n                .iter()\n                .map(|x| x.as_any().downcast_ref::<Utf8ViewArray>().unwrap().clone())\n                .collect::<Vec<_>>(),\n            widths,\n            output_height,\n            dtype,\n        )),\n        t => unimplemented!(\"horizontal_flatten not supported for data type {:?}\", t),\n    }\n}\n\nunsafe fn horizontal_flatten_unchecked_impl_generic<T>(\n    arrays: &[T],\n    widths: &[usize],\n    output_height: usize,\n    dtype: &ArrowDataType,\n) -> T\nwhere\n    T: StaticArray,\n{\n    assert!(!arrays.is_empty());\n    assert_eq!(widths.len(), arrays.len());\n\n    debug_assert!(widths.iter().all(|x| *x > 0));\n    debug_assert!(\n        arrays","sourceCodeStart":107,"sourceCodeEnd":143,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-compute/src/horizontal_flatten/mod.rs#L107-L143","documentation":"horizontal_flatten concatenates fixed-width element arrays (e.g. list/primitive views) into flat buffers. The generic dispatch only implements a fixed set of data types (primitives, utf8 views, etc.); any other physical type hits the catch-all `unimplemented!` arm. This is a hard not-implemented panic, not a recoverable error.","triggerScenarios":"Calling concat_arr / horizontal_flatten on an array whose physical type is not in the implemented match arms, e.g. a list of lists, fixed-size-lists of structs, or any other non-flattenable dtype.","commonSituations":"Concatenating nested list columns (list-of-lists) in Polars, or horizontally concatenating columns whose element dtype is a struct or another nested type.","solutions":["Flatten only one nesting level at a time: explode/flatten the outer list first, then apply again on the inner list.","Cast the element dtype to a supported type (primitive or string) before concatenating.","Manually restructure the data (e.g. melt/explode) so the operation operates on flat arrays.","If the dtype is legitimately needed, file/patch an implementation for that type in horizontal_flatten."],"exampleFix":"// before\nlet out = concat_arr(&[list_of_lists_arr]).unwrap();\n// after\nlet inner = list_of_lists_arr.explode().unwrap(); // flatten one level first\nlet out = concat_arr(&[inner_as_list_arr]).unwrap();","handlingStrategy":"validation","validationCode":"// Rust\nfn is_flattenable(dtype: &ArrowDataType) -> bool {\n    matches!(dtype, ArrowDataType::LargeList(f) | ArrowDataType::List(f)\n        if matches!(f.dtype(), ArrowDataType::_ _| Int8 | Int16 | Int32 | Int64 | UInt8 | UInt16 | UInt32 | UInt64 | Float32 | Float64 | Boolean))\n}","typeGuard":"fn is_list_of_flat(dtype: &DataType) -> bool {\n    matches!(dtype, DataType::List(inner) | DataType::Array(inner, _)\n        if inner.is_primitive() || inner.is_string())\n}","tryCatchPattern":null,"preventionTips":["Check the element dtype before calling concat/horizontal_flatten.","Avoid list-of-list columns unless explicitly supported.","Cast nested elements to primitives before flattening."],"tags":["rust","polars","not-implemented","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"}