{"record":{"id":"2f3bf2eefa3a2d46","repo":"databendlabs/databend","slug":"unsupported-column-type-for-encoding-2f3bf2","errorCode":null,"errorMessage":"Unsupported column type for encoding","messagePattern":"Unsupported column type for encoding","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/query/pipeline/transforms/src/processors/transforms/sorts/core/row_convert/variable.rs","lineNumber":798,"sourceCode":"    }\n\n    fn visit_variant(&mut self, column: BinaryColumn) -> Result<()> {\n        var_encode(\n            self.out,\n            column.iter(),\n            self.validity,\n            self.field.asc,\n            self.field.nulls_first,\n        );\n        Ok(())\n    }\n\n    fn visit_typed_column<T: ValueType>(\n        &mut self,\n        _column: T::Column,\n        _data_type: &DataType,\n    ) -> Result<()> {\n        unimplemented!(\"Unsupported column type for encoding\")\n    }\n}\n\n#[cfg(test)]\nmod tests {\n\n    use databend_common_base::base::OrderedFloat;\n    use databend_common_expression::Column;\n    use databend_common_expression::DataField;\n    use databend_common_expression::DataSchemaRefExt;\n    use databend_common_expression::FromData;\n    use databend_common_expression::SortColumnDescription;\n    use databend_common_expression::SortField;\n    use databend_common_expression::types::*;\n    use jsonb::OwnedJsonb;\n    use proptest::prelude::*;\n    use proptest::strategy::ValueTree;\n    use proptest::test_runner::TestRunner;","sourceCodeStart":780,"sourceCodeEnd":816,"githubUrl":"https://github.com/databendlabs/databend/blob/288d84d76e20a2f8f7173bda9691eb6ece301aa9/src/query/pipeline/transforms/src/processors/transforms/sorts/core/row_convert/variable.rs#L780-L816","documentation":"This is a catch-all panic in the sort-row encoding visitor: `visit_typed_column` is the default visitor method that every concrete ValueType must override. It is hit when the encoding logic encounters a column type whose ValueType visitor did not implement typed-column conversion, so the framework aborts with `unimplemented!` instead of silently producing wrong sort keys.","triggerScenarios":"Sorting (ORDER BY / top-k) over a column whose data type's ValueType<T> does not override `visit_typed_column` in `row_convert/variable.rs`, e.g. a newly added or unusual type (map, variant, exotic nested types) reaching the variable-length row encoder.","commonSituations":"Running ORDER BY on an exotic column type (e.g. VARIANT, MAP, or a newly supported type) that the sort key encoder hasn't been extended for; adding a new data type in the query engine without updating the sort row converters.","solutions":["Check which data type the failing query sorts on and confirm whether its ValueType visitor implements visit_typed_column in src/query/pipeline/transforms/src/processors/transforms/sorts/core/row_convert/","Implement visit_typed_column for that ValueType, encoding the column into the variable-length sort row","Work around in SQL by casting the column to a supported sortable type (e.g. CAST(variant_col AS VARCHAR)) before ORDER BY","File a Databend issue with the query and data type if the type should be supported"],"exampleFix":"// before (visitor for MyType falls through to default)\n// ... no visit_typed_column impl ...\n// after\nfn visit_typed_column(&mut self, column: MyTypeColumn, data_type: &DataType) -> Result<()> {\n    self.builder.push(my_type_sort_key(column), data_type)\n}","handlingStrategy":"validation","validationCode":"const SORTABLE_ENCODABLE_TYPES = [\"Nullable\",\"String\",\"Number\",\"Date\",\"Timestamp\",\"Decimal\"];\nfunction isSortEncodable(colType) {\n  return SORTABLE_ENCODABLE_TYPES.some(t => colType.startsWith(t)) ||\n         !/^(variant|map|array|tuple|geography|geometry)$/i.test(colType.replace(/^nullable\\((.*)\\)$/, \"$1\"));\n}\nif (!isSortEncodable(column.dataType)) {\n  column.query = `CAST(${column.name} AS VARCHAR)`;\n}","typeGuard":"function isVariantLike(dataType) {\n  const base = dataType.replace(/^Nullable\\((.*)\\)$/, \"$1\").toLowerCase();\n  return [\"variant\",\"map\",\"object\"].includes(base);\n}","tryCatchPattern":null,"preventionTips":["Restrict ORDER BY / sort keys to primitive types; cast VARIANT/MAP columns to VARCHAR before sorting","When adding a new ValueType in Databend, always override visit_typed_column rather than relying on the default","Keep a test that sorts every supported data type to catch unimplemented encoder paths early"],"tags":["rust","sort-encoding","unsupported-type"],"backgroundTag":"unsupported-operation","analyzedSha":"288d84d76e20a2f8f7173bda9691eb6ece301aa9","analyzedAt":"2026-09-11T11:29:36.208Z","contentChangedAt":"2026-09-11T11:29:36.208Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}