{"record":{"id":"4551dfd2fd4f7c53","repo":"pola-rs/polars","slug":"reverse-for-fixedsizelist-with-non-numeric-dtypes","errorCode":null,"errorMessage":"reverse for FixedSizeList with non-numeric dtypes not yet supported","messagePattern":"reverse for FixedSizeList with non-numeric dtypes not yet supported","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/ops/reverse.rs","lineNumber":100,"sourceCode":"                PlSmallStr::EMPTY,\n                (0..self.len() as IdxSize).rev().collect(),\n            );\n            unsafe { self.take_unchecked(&ca) }\n        }\n    }\n}\n\nimpl ChunkReverse for StringChunked {\n    fn reverse(&self) -> Self {\n        unsafe { self.as_binary().reverse().to_string_unchecked() }\n    }\n}\n\n#[cfg(feature = \"dtype-array\")]\nimpl ChunkReverse for ArrayChunked {\n    fn reverse(&self) -> Self {\n        if !self.inner_dtype().is_primitive_numeric() {\n            todo!(\"reverse for FixedSizeList with non-numeric dtypes not yet supported\")\n        }\n        let ca = self.rechunk();\n        let arr = ca.downcast_as_array();\n        let values = arr.values().as_ref();\n\n        let mut builder =\n            get_fixed_size_list_builder(ca.inner_dtype(), ca.len(), ca.width(), ca.name().clone())\n                .expect(\"not yet supported\");\n\n        // SAFETY, we are within bounds\n        unsafe {\n            if arr.null_count() == 0 {\n                for i in (0..arr.len()).rev() {\n                    builder.push_unchecked(values, i)\n                }\n            } else {\n                let validity = arr.validity().unwrap();\n                for i in (0..arr.len()).rev() {","sourceCodeStart":82,"sourceCodeEnd":118,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/chunked_array/ops/reverse.rs#L82-L118","documentation":"ChunkReverse for ArrayChunked (FixedSizeList) is only implemented for primitive numeric inner dtypes; it manipulates raw values in a typed builder. For any other inner dtype (string, struct, etc.) there is no reverse implementation, so the code calls todo! which panics with this message.","triggerScenarios":"Calling Series::reverse (or an expression like col.reverse()) on a FixedSizeList column whose element dtype is not a primitive numeric type.","commonSituations":"Reversing fixed-size list columns of strings, decimals, or nested types; generic reverse applied over all DataFrame columns.","solutions":["Avoid reversing the FixedSizeList column; instead skip it or handle it separately","Convert to a supported dtype first, e.g. cast the inner values to a numeric type before reversing","Reverse via a generic fallback: explode/rebuild, or use list operations on a List dtype instead of FixedSizeList"],"exampleFix":"// before\nlet r = fixed_size_list_col.reverse(); // todo! for non-numeric inner dtype\n// after\nlet r = fixed_size_list_col\n    .cast(&DataType::List(Box::new(DataType::Int64)))?\n    .reverse();","handlingStrategy":"type-guard","validationCode":"if let DataType::Array(inner, _) = s.dtype() {\n    if !inner.is_primitive_numeric() { /* avoid .reverse(), use alternative */ }\n}","typeGuard":"fn reverse_supported(s: &Series) -> bool {\n    match s.dtype() { DataType::Array(inner, _) => inner.is_primitive_numeric(), _ => true }\n}","tryCatchPattern":"let r = std::panic::catch_unwind(|| col.reverse());","preventionTips":["Check inner dtype of FixedSizeList columns before reversing","Cast to List or numeric inner dtype first","Handle non-numeric columns separately in generic reverse code"],"tags":["rust","polars","fixed-size-list","not-implemented"],"backgroundTag":"method-not-implemented","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"}