databendlabs/databend · error
Unsupported column type for encoding
Error message
Unsupported column type for encoding
What it means
The sort row-encoding fixed-size visitor encodes columns into fixed-width sort keys. Its default visit_typed_column arm raises unimplemented!("Unsupported column type for encoding") for column types that cannot be represented as fixed-size rows. Sorting (ORDER BY / top-N) on such a column type via the fixed encoder is not supported.
Solutions
- Cast the sort column to a supported comparable type (e.g. VARCHAR for variant, or sort by an extracted scalar)
- Sort by a simpler expression/key (e.g. a numeric or string column) instead of the nested type
- Upgrade Databend if the type is standard — encoder coverage grows over releases
- Implement the missing type arm in the fixed encoder if you maintain the code, or route it to the variable encoder
Example fix
// before SELECT * FROM t ORDER BY json_col; // after SELECT * FROM t ORDER BY json_col::string;
Defensive patterns
Strategy: validation
Validate before calling
-- sql: verify sort keys are encoder-friendly scalar types
SELECT data_type FROM information_schema.columns
WHERE table_name = 't' AND column_name IN ('sort_col');
-- prefer Integer/Float/String/Date/Timestamp types for ORDER BY Type guard
fn sortable_fixed_type(ty: &DataType) -> bool {
matches!(ty, DataType::Number(_) | DataType::String | DataType::Date
| DataType::Timestamp | DataType::Boolean | DataType::Nullable(box inner)
if matches!(**inner, DataType::Number(_) | DataType::String))
|| matches!(ty, DataType::Number(_) | DataType::String | DataType::Date | DataType::Timestamp | DataType::Boolean)
} Prevention
- Cast nested/complex types to strings or scalars before ORDER BY
- Sort on extracted fields rather than whole variant/map/array values
- Review release notes for sorter type-coverage before relying on new types in sort keys
When it happens
Trigger: A query sorts by, or uses in a sort key, a column whose type the fixed-size row encoder lacks an arm for (e.g. complex/nested or large types that must use the variable encoder).
Common situations: ORDER BY on unusual types (arrays, maps, variants, bitmaps) reaching the fixed encoder; optimizer choosing fixed encoding for a newly added data type; window functions sorting over unsupported columns.
Related errors
- Unsupported column type for length calculation
- internal error: entered unreachable code
- {}
- Temp table id used up
- Invalid temp table desc
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/f5d590ae102bb654.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/pipeline/transforms/src/processors/transforms/sorts/core/row_convert/fixed.rs:460
fn visit_interval(&mut self, buffer: Buffer<months_days_micros>) -> Result<()> {
let buffer_bytes = buffer_to_bytes(self.buffer);
fixed_encode(
buffer_bytes,
self.offsets,
buffer,
self.validity,
self.field.asc,
self.field.nulls_first,
);
Ok(())
}
fn visit_typed_column<T: ValueType>(
&mut self,
_column: T::Column,
_data_type: &DataType,
) -> Result<()> {
unimplemented!("Unsupported column type for encoding")
}
}
#[cfg(test)]
mod tests {
use std::sync::Arc;
use databend_common_expression::DataField;
use databend_common_expression::DataSchemaRef;
use databend_common_expression::DataSchemaRefExt;
use databend_common_expression::SortColumnDescription;
use databend_common_expression::SortField;
use proptest::prelude::*;
use proptest::strategy::Strategy;
use proptest::strategy::ValueTree;
use proptest::test_runner::TestRunner;
use super::super::test_util::*;View on GitHub (pinned to 288d84d76e)