pola-rs/polars · error
reverse for FixedSizeList with non-numeric dtypes not yet…
Error message
reverse for FixedSizeList with non-numeric dtypes not yet supported
What it means
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.
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
Example fix
// before
let r = fixed_size_list_col.reverse(); // todo! for non-numeric inner dtype
// after
let r = fixed_size_list_col
.cast(&DataType::List(Box::new(DataType::Int64)))?
.reverse(); Defensive patterns
Strategy: type-guard
Validate before calling
if let DataType::Array(inner, _) = s.dtype() {
if !inner.is_primitive_numeric() { /* avoid .reverse(), use alternative */ }
} Type guard
fn reverse_supported(s: &Series) -> bool {
match s.dtype() { DataType::Array(inner, _) => inner.is_primitive_numeric(), _ => true }
} Try / catch
let r = std::panic::catch_unwind(|| col.reverse());
Prevention
- 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
When it happens
Trigger: Calling Series::reverse (or an expression like col.reverse()) on a FixedSizeList column whose element dtype is not a primitive numeric type.
Common situations: Reversing fixed-size list columns of strings, decimals, or nested types; generic reverse applied over all DataFrame columns.
Related errors
- Dynamic MinMax is not yet implemented for
- FixedSizeListArray::arr_from_iter_with_dtype called with…
- horizontal_flatten not supported for data type
- not implemented for
- {0}
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/4551dfd2fd4f7c53.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-core/src/chunked_array/ops/reverse.rs:100
PlSmallStr::EMPTY,
(0..self.len() as IdxSize).rev().collect(),
);
unsafe { self.take_unchecked(&ca) }
}
}
}
impl ChunkReverse for StringChunked {
fn reverse(&self) -> Self {
unsafe { self.as_binary().reverse().to_string_unchecked() }
}
}
#[cfg(feature = "dtype-array")]
impl ChunkReverse for ArrayChunked {
fn reverse(&self) -> Self {
if !self.inner_dtype().is_primitive_numeric() {
todo!("reverse for FixedSizeList with non-numeric dtypes not yet supported")
}
let ca = self.rechunk();
let arr = ca.downcast_as_array();
let values = arr.values().as_ref();
let mut builder =
get_fixed_size_list_builder(ca.inner_dtype(), ca.len(), ca.width(), ca.name().clone())
.expect("not yet supported");
// SAFETY, we are within bounds
unsafe {
if arr.null_count() == 0 {
for i in (0..arr.len()).rev() {
builder.push_unchecked(values, i)
}
} else {
let validity = arr.validity().unwrap();
for i in (0..arr.len()).rev() {View on GitHub (pinned to fe841f959e)