{"record":{"id":"624a0489062691c7","repo":"pola-rs/polars","slug":"unsupported-in-row-encoding","errorCode":null,"errorMessage":"Unsupported in row encoding","messagePattern":"Unsupported in row encoding","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-core/src/chunked_array/ops/row_encode.rs","lineNumber":113,"sourceCode":"        | DataType::Null\n        | DataType::Time\n        | DataType::Date\n        | DataType::Datetime(_, _)\n        | DataType::Duration(_) => None,\n\n        #[cfg(feature = \"dtype-categorical\")]\n        DataType::Categorical(_, mapping) | DataType::Enum(_, mapping) => {\n            use polars_row::RowEncodingCategoricalContext;\n\n            Some(RowEncodingContext::Categorical(\n                RowEncodingCategoricalContext {\n                    is_enum: matches!(dtype, DataType::Enum(_, _)),\n                    mapping: mapping.clone(),\n                },\n            ))\n        },\n\n        DataType::Unknown(_) => panic!(\"Unsupported in row encoding\"),\n\n        #[cfg(feature = \"object\")]\n        DataType::Object(_) => panic!(\"Unsupported in row encoding\"),\n\n        #[cfg(feature = \"dtype-decimal\")]\n        DataType::Decimal(precision, _) => Some(RowEncodingContext::Decimal(*precision)),\n\n        #[cfg(feature = \"dtype-array\")]\n        DataType::Array(dtype, _) => get_row_encoding_context(dtype),\n        DataType::List(dtype) => get_row_encoding_context(dtype),\n        #[cfg(feature = \"dtype-struct\")]\n        DataType::Struct(fs) => {\n            let mut ctxts = Vec::new();\n\n            for (i, f) in fs.iter().enumerate() {\n                if let Some(ctxt) = get_row_encoding_context(f.dtype()) {\n                    ctxts.reserve(fs.len());\n                    ctxts.extend(std::iter::repeat_n(None, i));","sourceCodeStart":95,"sourceCodeEnd":131,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-core/src/chunked_array/ops/row_encode.rs#L95-L131","documentation":"get_row_encoding_context maps a DataType to its row-encoding context so columns can be sorted/joined via the row encoding. DataType::Unknown has no row-encoding representation, so the function panics rather than producing a meaningless encoding.","triggerScenarios":"Using row-encoded operations (sort by multiple columns, join on keys, _get_rows_encoded*) where one of the key columns has DataType::Unknown — typically a column whose dtype could not be inferred or an unmaterialized/detached dtype.","commonSituations":"Constructing DataFrames with unknown dtypes (e.g. from empty or heterogeneous sources) and then sorting/joining on them; passing partially-initialized series into frame operations.","solutions":["Ensure the key column has a concrete dtype before the row-encoded operation (cast to a supported dtype)","Trace why the column is Unknown (empty frame, inference failure) and fix at construction time","Exclude Unknown-dtype columns from sort/join keys"],"exampleFix":"// before\nkeys.sort([unknown_col]); // panics: Unsupported in row encoding\n// after\nlet col = unknown_col.cast(&DataType::Int64)?; // or fix inference\nkeys.sort([col]);","handlingStrategy":"type-guard","validationCode":"if matches!(key.dtype(), DataType::Unknown(_)) {\n    return Err(\"cannot row-encode key with Unknown dtype; cast it first\");\n}","typeGuard":"fn row_encoding_supported(dt: &DataType) -> bool {\n    !matches!(dt, DataType::Unknown(_) | DataType::Object(_) | DataType::Null)\n}","tryCatchPattern":null,"preventionTips":["Resolve dtype inference before sorting/joining","Cast Unknown columns to concrete dtypes at frame construction","Exclude non-encodable columns from multi-key operations"],"tags":["rust","polars","row-encoding","unknown-dtype"],"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"}