{"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/df599052daf96e7a9cc30a3b0c6bd25d6947e3c0/crates/polars-compute/src/horizontal_flatten/mod.rs#L107-L143","documentation":"Panic from the horizontal_flatten kernel in polars-compute, the low-level routine behind concat_arr (horizontal concatenation into a fixed-size-list / Array dtype). The match on the Arrow physical type only implements Null, Boolean, Primitive, LargeBinary, Struct, LargeList, FixedSizeList, BinaryView and Utf8View; any other physical layout reaches unimplemented!(). Typical leftovers are the legacy Utf8/LargeUtf8 string layouts, Map, Dictionary, or Extension types.","triggerScenarios":"Calling a concat_arr-based API (e.g. pl.concat_arr / expressions that build DataType::Array columns) where the inner values array materializes with a physical type not in the supported set - for example after casting a String column to legacy Utf8, or with Map/Dictionary/Extension inner dtypes.","commonSituations":"Custom casting pipelines that force old Arrow string layouts, interop code that produces Map or Dictionary arrays, or older polars versions where String was not yet Utf8View-based.","solutions":["Cast the inner columns to a supported dtype before concatenating (String and Binary are fine because they map to Utf8View/BinaryView in current polars)","Check the physical type of inputs first: use the modern String dtype instead of legacy Utf8/LargeUtf8 layouts","Upgrade polars - newer kernels cover more physical types","If you control the data, rebuild the arrays so Map/Dictionary/Extension are exploded into Struct/Utf8View before concat_arr"],"exampleFix":"# before\npl.concat_arr([\n    df.select(pl.col(\"legacy_str\").cast(pl.Utf8)).to_series(),  # legacy layout\n    df[\"vals\"]\n])\n\n# after\npl.concat_arr([\n    df[\"legacy_str\"].cast(pl.String),  # Utf8View physical type, supported\n    df[\"vals\"]\n])","handlingStrategy":"validation","validationCode":"# Python: verify inner physical layout before concat_arr-style ops\nSUPPORTED_INNER = {pl.Null, pl.Boolean, pl.String, pl.Binary}\nSUPPORTED_INNER |= {dt for dt in pl.INTEGER_DTYPES + pl.FLOAT_DTYPES}\ninner = df[\"col\"].dtype\nif isinstance(inner, pl.List):\n    inner = inner.inner\nif isinstance(inner, pl.Array):\n    inner = inner.inner\nassert inner in SUPPORTED_INNER or inner.is_numeric(), f\"unsupported inner dtype {inner}\"","typeGuard":"def concat_arr_safe(cols: list[pl.Series]) -> bool:\n    inner = cols[0].dtype\n    ok = inner.is_numeric() or inner in (pl.Boolean, pl.String, pl.Binary, pl.Null)\n    ok = ok and all(c.dtype.base_type() == inner.base_type() for c in cols)\n    if isinstance(inner, (pl.List, pl.Struct, pl.Array)):\n        ok = ok and concat_arr_safe([pl.Series([v]) for v in []]) or True\n    return ok","tryCatchPattern":"try:\n    out = pl.concat_arr(cols)\nexcept pl.exceptions.PanicException:\n    # unsupported physical layout: cast inputs and retry\n    out = pl.concat_arr([c.cast(pl.String) if c.dtype == pl.Utf8 else c for c in cols])","preventionTips":["Always use the modern pl.String dtype; never cast to legacy Utf8 layouts","Explode Map/Dictionary/Extension arrays into Struct/String columns before concat_arr","Pin a recent polars version so String maps to Utf8View"],"tags":["rust","polars","panic","unimplemented","concat-arr","fixed-size-list","dtype","arrow"],"backgroundTag":null,"analyzedSha":"df599052daf96e7a9cc30a3b0c6bd25d6947e3c0","analyzedAt":"2026-08-16T12:10:03.978Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}