{"record":{"id":"2cc2a60b9fa47370","repo":"pola-rs/polars","slug":"not-implemented-2cc2a6","errorCode":null,"errorMessage":"not implemented","messagePattern":"not implemented","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-compute/src/gather/fixed_size_list.rs","lineNumber":58,"sourceCode":"fn get_leaves(array: &FixedSizeListArray) -> &dyn Array {\n    if let Some(array) = array.values().as_any().downcast_ref::<FixedSizeListArray>() {\n        get_leaves(array)\n    } else {\n        &**array.values()\n    }\n}\n\nfn get_buffer_and_size(array: &dyn Array) -> (&[u8], usize) {\n    match array.dtype().to_physical_type() {\n        PhysicalType::Primitive(primitive) => with_match_primitive_type!(primitive, |$T| {\n\n            let arr = array.as_any().downcast_ref::<PrimitiveArray<$T>>().unwrap();\n            let values = arr.values();\n            (bytemuck::cast_slice(values), size_of::<$T>())\n\n        }),\n        _ => {\n            unimplemented!()\n        },\n    }\n}\n\nunsafe fn from_buffer(mut buf: ManuallyDrop<Vec<u8>>, dtype: &ArrowDataType) -> ArrayRef {\n    match dtype.to_physical_type() {\n        PhysicalType::Primitive(primitive) => with_match_primitive_type!(primitive, |$T| {\n            let ptr = buf.as_mut_ptr();\n            let len_units = buf.len();\n            let cap_units = buf.capacity();\n\n            let buf = Vec::from_raw_parts(\n                ptr as *mut $T,\n                len_units / size_of::<$T>(),\n                cap_units / size_of::<$T>(),\n            );\n\n            PrimitiveArray::from_data_default(buf.into(), None).boxed()","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/pola-rs/polars/blob/9b5d73fd00236295624374b075d16b1fe6ec6df9/crates/polars-compute/src/gather/fixed_size_list.rs#L40-L76","documentation":"The FixedSizeList take kernel gathers rows by byte-copying contiguous element buffers, so its helper get_buffer_and_size only implements PhysicalType::Primitive. Taking from a pl.Array(inner, width) column whose element type is not Arrow-primitive (String, Boolean, nested List/Struct) falls into the wildcard arm and panics 'not implemented'.","triggerScenarios":"Any operation lowering to gather on a FixedSizeListArray with non-primitive elements: Series.gather([..]), df[[0, 2]] row selection, filter, join reindexing, group_by output reordering - on columns like pl.Array(pl.String, 2) or pl.Array(pl.Boolean, 3).","commonSituations":"Embedding/vector pipelines that store fixed-size string tag arrays or boolean masks per row; code validated with pl.Array(pl.Float32, 128) (primitive, works) that is later pointed at Array(pl.String, k) and panics during a filter or join.","solutions":["Cast Array to List around the gather: s.cast(pl.List(inner)).gather(idx).cast(pl.Array(inner, width))","Keep Array element types primitive in stored schemas (encode strings as fixed-size binary or id hashes)","Upstream: route non-primitive FixedSizeList elements through a generic take path instead of the byte-copy fast path"],"exampleFix":"# before\ns = pl.Series([[\"a\", \"b\"]], dtype=pl.Array(pl.String, 2))\ns.gather([0, 1])  # unimplemented: element type not primitive\n# after\ns.cast(pl.List(pl.String)).gather([0, 1]).cast(pl.Array(pl.String, 2))","handlingStrategy":"validation","validationCode":"# only gather Array columns whose element dtype is primitive\nPRIMITIVE = {pl.Int8, pl.Int16, pl.Int32, pl.Int64, pl.UInt8, pl.UInt16, pl.UInt32,\n             pl.UInt64, pl.Float32, pl.Float64}\n\ndef array_gather_safe(s: pl.Series, idx) -> pl.Series:\n    if s.dtype == pl.Array and s.dtype.inner.is_nested():\n        return s.cast(pl.List(s.dtype.inner)).gather(idx).cast(s.dtype)\n    return s.gather(idx)","typeGuard":"def is_primitive_element_array(dtype) -> bool:\n    return dtype == pl.Array and not dtype.inner.is_nested() and dtype.inner != pl.Boolean","tryCatchPattern":null,"preventionTips":["Keep pl.Array element types primitive in stored schemas (numbers, dates)","Wrap gather/select behind a helper that casts Array<non-primitive> to List first","Test row-selection code against string/boolean element arrays, not just numeric"],"tags":["polars","fixed-size-list","array-dtype","gather","panic","unimplemented-macro"],"backgroundTag":"fixed-size-list-gather","analyzedSha":"9b5d73fd00236295624374b075d16b1fe6ec6df9","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}