{"record":{"id":"aeff59f9f44f8863","repo":"pola-rs/polars","slug":"not-implemented-for-dtype-macros","errorCode":null,"errorMessage":"not implemented for dtype {:?}","messagePattern":"not implemented for dtype (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/macros.rs","lineNumber":38,"sourceCode":"    $key_type:expr, | $_:tt $T:ident | $($body:tt)*\n) => ({\n    macro_rules! __with_ty__ {( $_ $T:ident ) => ( $($body)* )}\n    use $crate::datatypes::DataType::*;\n    match $key_type {\n        Int8 => __with_ty__! { Int8Type },\n        Int16 => __with_ty__! { Int16Type },\n        Int32 => __with_ty__! { Int32Type },\n        Int64 => __with_ty__! { Int64Type },\n        Int128 => __with_ty__! { Int128Type },\n        UInt8 => __with_ty__! { UInt8Type },\n        UInt16 => __with_ty__! { UInt16Type },\n        UInt32 => __with_ty__! { UInt32Type },\n        UInt64 => __with_ty__! { UInt64Type },\n        UInt128 => __with_ty__! { UInt128Type },\n        Float16 => __with_ty__! { Float16Type },\n        Float32 => __with_ty__! { Float32Type },\n        Float64 => __with_ty__! { Float64Type },\n        dt => panic!(\"not implemented for dtype {:?}\", dt),\n    }\n})}\n","sourceCodeStart":20,"sourceCodeEnd":41,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/macros.rs#L20-L41","documentation":"The apply/with-physical-type macro in polars-utils panics when it encounters an Arrow DataType for which no corresponding physical type arm is implemented. In this case BinaryArrayBuilder receives a dtype outside the handled set of numeric/float types and hits the catch-all `dt => panic!(\"not implemented for dtype {:?}\", dt)`. It signals that a dtype-dispatch operation lacks support for the given type.","triggerScenarios":"Constructing or operating on a BinaryArrayBuilder (or similar macro-dispatched builder) with an ArrowDataType that the macro does not cover, e.g. wrong dtype passed to BinaryArrayBuilder::new or a match dispatch over an unhandled type variant.","commonSituations":"Extension/FFI code creating builders with mismatched dtypes; schema-driven code feeding arbitrary dtypes into a fixed dispatch table; new Arrow dtype variants added before the dispatch arms are updated.","solutions":["Pass a supported dtype to the builder instead of inferring it from data (e.g. use the correct Utf8/Binary/BinaryView dtype for BinaryArrayBuilder)","Add (or request) a macro arm for the missing dtype if the type is legitimately needed","Guard the call site: check the dtype against supported variants before constructing the builder"],"exampleFix":"// before\nlet b = BinaryArrayBuilder::<i64>::new(dtype); // dtype may be unsupported\n// after\nmatch dtype {\n    ArrowDataType::Binary | ArrowDataType::Utf8 => {},\n    other => panic!(\"unsupported builder dtype {:?}\", other),\n}\nlet b = BinaryArrayBuilder::<i64>::new(dtype);","handlingStrategy":"type-guard","validationCode":"// Rust: check dtype support before building\nfn supported(dtype: &ArrowDataType) -> bool {\n    matches!(dtype, ArrowDataType::Binary | ArrowDataType::LargeBinary | ArrowDataType::Utf8 | ArrowDataType::LargeUtf8)\n}","typeGuard":"fn is_binary_like(dt: &ArrowDataType) -> bool { matches!(dt, ArrowDataType::Binary | ArrowDataType::LargeBinary) }","tryCatchPattern":null,"preventionTips":["Always pass an explicit supported dtype to BinaryArrayBuilder::new","Whitelist dtypes before schema-driven builder construction","Check the dtype-dispatch macro's covered arms when adding new Arrow types"],"tags":["rust","dtype","arrow","dispatch"],"backgroundTag":"unsupported-dtype","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"}