{"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":440,"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":422,"sourceCodeEnd":458,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/series/from.rs#L422-L458","documentation":"Converting Arrow `Dictionary` arrays into Polars Series requires the `dtype-categorical` feature, since Polars represents dictionaries as Categorical/Enum dtypes. When that feature is not compiled in, `_try_from_arrow_unchecked_with_md` hits the non-feature match arm for `ArrowDataType::Dictionary` and panics, instructing the user to enable the feature.","triggerScenarios":"Reading an Arrow IPC/Feather/Parquet file containing dictionary-encoded string columns, or calling `Series::_try_from_arrow_unchecked_with_md` with Dictionary chunks, while polars-core lacks the `dtype-categorical` feature.","commonSituations":"Minimal-features polars installs reading dictionary-encoded Parquet produced by pyarrow; dependency trees that disable default features; cross-language data exchange where upstream tools dictionary-encode low-cardinality strings by default.","solutions":["Enable the feature: `polars-core = { version = \"...\", features = [\"dtype-categorical\"] }` (or add `dtype-categorical` to the polars meta-crate features).","Re-encode the Arrow data without dictionary encoding before conversion (e.g. cast Dictionary to plain Utf8/Binary on the producer side).","Use `arrow`-level casting to decode dictionaries into dense arrays before handing chunks to polars."],"exampleFix":"// before (Cargo.toml)\npolars = { version = \"0.41\", default-features = false, features = [\"parquet\"] }\n\n// after\npolars = { version = \"0.41\", default-features = false, features = [\"parquet\", \"dtype-categorical\"] }","handlingStrategy":"fallback","validationCode":"// detect dictionary-encoded arrow data before conversion\nlet is_dict = matches!(arr.data_type(), ArrowDataType::Dictionary(_, _, _));","typeGuard":"fn is_dictionary_type(dt: &ArrowDataType) -> bool {\n    matches!(dt, ArrowDataType::Dictionary(_, _, _))\n}","tryCatchPattern":"// panic-based; guard before conversion:\nif is_dictionary_type(chunk.data_type()) && !cfg!(feature = \"dtype-categorical\") {\n    let decoded = polars_arrow::compute::cast::cast(chunk, &ArrowDataType::LargeUtf8)?;\n    // convert decoded instead\n}","preventionTips":["Enable `dtype-categorical` whenever reading Parquet/IPC from other ecosystems.","Ask producers to disable dictionary encoding or cast dictionaries to strings upstream.","List all dtype features explicitly when using default-features = false."],"tags":["rust","polars","arrow","feature-flag","categorical"],"backgroundTag":"feature-not-enabled","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"}