{"record":{"id":"5cc120cfa23aa837","repo":"pola-rs/polars","slug":"take-not-supported-for-data-type","errorCode":null,"errorMessage":"Take not supported for data type {:?}","messagePattern":"Take not supported for data type (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-compute/src/gather/mod.rs","lineNumber":85,"sourceCode":"            structure::take_unchecked(array, indices).boxed()\n        },\n        LargeList => {\n            let array = values.as_any().downcast_ref().unwrap();\n            Box::new(list::take_unchecked::<i64>(array, indices))\n        },\n        FixedSizeList => {\n            let array = values.as_any().downcast_ref().unwrap();\n            fixed_size_list::take_unchecked(array, indices)\n        },\n        BinaryView => {\n            let array: &BinaryViewArray = values.as_any().downcast_ref().unwrap();\n            binview::take_binview_unchecked(array, indices).boxed()\n        },\n        Utf8View => {\n            let array: &Utf8ViewArray = values.as_any().downcast_ref().unwrap();\n            binview::take_binview_unchecked(array, indices).boxed()\n        },\n        t => unimplemented!(\"Take not supported for data type {:?}\", t),\n    }\n}\n\n/// Naive default implementation\nunsafe fn take_unchecked_impl_generic<T>(\n    values: &T,\n    indices: &IdxArr,\n    new_null_func: &dyn Fn(ArrowDataType, usize) -> T,\n) -> T\nwhere\n    T: StaticArray + ArrayFromIterDtype<std::option::Option<Box<dyn array::Array>>>,\n{\n    if values.null_count() == values.len() || indices.null_count() == indices.len() {\n        return new_null_func(values.dtype().clone(), indices.len());\n    }\n\n    match (indices.has_nulls(), values.has_nulls()) {\n        (true, true) => {","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-compute/src/gather/mod.rs#L67-L103","documentation":"`take_unchecked` in polars-compute implements the gather/take operation by matching on the array's data type. Types without a dedicated take kernel hit `t => unimplemented!(\"Take not supported for data type {:?}\", t)`, which panics naming the dtype. Like error 60, this reflects kernel coverage gaps rather than bad input indices.","triggerScenarios":"Calling `take_unchecked(values, indices)` on an array whose `ArrowDataType` has no implemented take branch — e.g. less common dtypes (certain nested/extension types) not listed in the match.","commonSituations":"Generic selection/filter code paths hitting an unusual column dtype; newly added Arrow types not yet wired into the gather kernel; DataFrame ops on extension or dictionary-adjacent types.","solutions":["Convert the column to a supported dtype (e.g. cast to Utf8View/Primitive) before taking.","Use the non-unchecked / generic take API that supports the type, or fall back to a row-wise implementation.","Upgrade polars — new releases continuously add take kernel coverage; otherwise file an upstream issue for the dtype."],"exampleFix":"// before\nlet out = unsafe { take_unchecked(values, indices) }; // panics for unsupported dtype\n// after\nlet values = if is_unsupported_dtype(values.dtype()) {\n    values.cast(&fallback_dtype)?\n} else {\n    values.clone()\n};\nlet out = unsafe { take_unchecked(&values, indices) };","handlingStrategy":"fallback","validationCode":"fn take_supported(dtype: &ArrowDataType) -> bool {\n    matches!(\n        dtype.to_physical_type(),\n        ArrowDataType::Null | ArrowDataType::Boolean\n            | ArrowDataType::Int8 | ArrowDataType::Int16 | ArrowDataType::Int32\n            | ArrowDataType::Int64 | ArrowDataType::UInt8 | ArrowDataType::UInt16\n            | ArrowDataType::UInt32 | ArrowDataType::UInt64\n            | ArrowDataType::Float32 | ArrowDataType::Float64\n            | ArrowDataType::Utf8 | ArrowDataType::LargeUtf8\n            | ArrowDataType::Binary | ArrowDataType::LargeBinary\n            | ArrowDataType::Utf8View | ArrowDataType::BinaryView\n    ) // extend to cover all branches of take_unchecked\n}","typeGuard":null,"tryCatchPattern":"// Panics cannot be caught in stable Rust; choose the path up front:\nlet out = if take_supported(values.dtype()) {\n    unsafe { take_unchecked(values, indices) }\n} else {\n    take_fallback(values, indices)? // row-wise / cast-based path\n};","preventionTips":["Cast unsupported dtypes to a supported one before take/gather","Keep polars versions current to benefit from expanding kernel coverage","In generic pipelines, dispatch on dtype and provide a manual fallback gather"],"tags":["arrow","polars","take","unsupported-dtype"],"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"}