{"record":{"id":"7a94be055dd00fa3","repo":"pola-rs/polars","slug":"activate-dtype-categorical-to-convert-dictionary-a","errorCode":null,"errorMessage":"activate dtype-categorical to convert dictionary arrays","messagePattern":"activate dtype-categorical to convert dictionary arrays","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/series/from.rs","lineNumber":438,"sourceCode":"                                }).map(Some)\n                            } else {\n                                Ok(None)\n                            }\n                        }).try_collect_arr_trusted()?;\n\n                        *chunk = arr_128.to(ArrowDataType::Int128).to_boxed();\n                    }\n\n                    let s = Int128Chunked::from_chunks(name, chunks)\n                        .into_decimal_unchecked(*precision, *scale)\n                        .into_series();\n                    Ok(s)\n                })\n            },\n            ArrowDataType::Null => Ok(new_null(name, &chunks)),\n            #[cfg(not(feature = \"dtype-categorical\"))]\n            ArrowDataType::Dictionary(_, _, _) => {\n                panic!(\"activate dtype-categorical to convert dictionary arrays\")\n            },\n            #[cfg(feature = \"dtype-categorical\")]\n            ArrowDataType::Dictionary(key_type, _, _) => {\n                let polars_dtype = DataType::from_arrow(chunks[0].dtype(), md);\n\n                let mut series_iter = chunks.into_iter().map(|arr| {\n                    import_arrow_dictionary_array(name.clone(), arr, key_type, &polars_dtype)\n                });\n\n                let mut first = series_iter.next().unwrap()?;\n\n                for s in series_iter {\n                    first.append_owned(s?)?;\n                }\n\n                Ok(first)\n            },\n            #[cfg(feature = \"object\")]","sourceCodeStart":420,"sourceCodeEnd":456,"githubUrl":"https://github.com/pola-rs/polars/blob/68506541d2de983056c9eb244e1ea05fab377dfc/crates/polars-core/src/series/from.rs#L420-L456","documentation":"Importing Arrow dictionary arrays (dictionary-encoded strings/categoricals) into polars is implemented only under the dtype-categorical cargo feature. With that feature disabled, the Series-from-Arrow conversion hits a cfg-gated panic: 'activate dtype-categorical to convert dictionary arrays'.","triggerScenarios":"Creating a Series/DataFrame from an Arrow RecordBatch or table that contains Dictionary-typed columns (common when interoping with Arrow/duckdb/pandas via Arrow FFI) while the polars dependency was built without the dtype-categorical feature.","commonSituations":"Minimal-feature Cargo setups (default-features = false plus a short feature list) that later receive dictionary-encoded data; version bumps where feature sets were trimmed; polars-arrow interop code paths that worked with full feature builds but not slim builds.","solutions":["Enable the feature: polars = { version = \"...\", features = [\"dtype-categorical\"] }","Pre-decode dictionary arrays to plain Utf8 on the Arrow side before handing them to polars","Or move to a full-featured build (default features or the 'lazy' bundle) for the interop binary"],"exampleFix":"# before\npolars = { version = \"0.4X\", default-features = false, features = [\"fmt\"] }\n\n# after\npolars = { version = \"0.4X\", default-features = false, features = [\"fmt\", \"dtype-categorical\"] }","handlingStrategy":"fallback","validationCode":"fn has_dict_columns(batches: &[arrow_array::RecordBatch]) -> bool {\n    batches.iter().any(|b| {\n        b.schema().fields().iter().any(|f| matches!(f.data_type(), arrow_schema::DataType::Dictionary(_, _)))\n    })\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["List dtype-categorical in polars features whenever Arrow dictionary data may arrive","Decode dictionary arrays to Utf8 before conversion if the feature cannot be enabled","Add an integration test for the Arrow interop path under the exact feature set you ship"],"tags":["rust","polars","arrow","dictionary-array","cargo-feature","categorical"],"backgroundTag":"missing-feature-flag","analyzedSha":"68506541d2de983056c9eb244e1ea05fab377dfc","analyzedAt":"2026-08-19T12:15:06.350Z","contentChangedAt":"2026-08-19T12:15:06.350Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}