influxdata/influxdb · error
sorted column is not in the schema
Error message
sorted column {column_name} is not in the schema What it means
statistics_min_max panics when the sorted column name cannot be found in one of the input plans' schemas. The function assumes every input plan's schema contains the column the plan is sorted by; if a projection or rename removed it, index_of fails and the code deliberately panics with this message.
Solutions
- Verify column_name exists in every input plan schema before calling statistics_min_max
- Check for case mismatches in column naming between plans
- Fix the upstream optimizer/projection rule so the sorted column is preserved in each input's schema
Example fix
// before
let Ok(sorted_col_index) = input_schema.index_of(column_name) else {
panic!("sorted column {column_name} is not in the schema");
};
// after
let Some(sorted_col_index) = input_schema.index_of(column_name) else {
return internal_err!("sorted column {column_name} is not in schema of input {}", input.name());
}; Defensive patterns
Strategy: validation
Validate before calling
for input in plan.inputs() {
assert!(input.schema().index_of(column_name).is_ok(),
"{} not in {}", column_name, input.schema());
} Type guard
fn has_column(schema: &SchemaRef, col: &str) -> bool {
schema.fields().iter().any(|f| f.name() == col)
} Try / catch
// panic-based; guard with catch_unwind or pre-validate index_of before calling
Prevention
- Confirm sort column survives projections
- Normalize column name casing before lookup
- Add schema assertions in optimizer tests
When it happens
Trigger: Calling statistics_min_max (directly or via tests) with a column_name that is not present in at least one input plan's schema — e.g. after a projection dropped or renamed the sort column.
Common situations: Optimizer pushed a projection that eliminated the sort column; schema case mismatch (column stored as 'Time' but queried as 'time'); custom plans where inputs have divergent schemas.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- column id in series key should be valid
- min ( ) > max ( )
- should have a single merged statistic
- should not be absent
- We should never receive an unspecified type in a TableBatch
AI-assisted analysis of influxdata/influxdb@06200ef96b (2026-09-19).
Data as JSON: /api/errors/2b8e11d58621770e.
Report an issue: GitHub.
Appendix: source
Thrown at core/iox_query/src/statistics/aggregate_per_plan.rs:255
Arc::clone(plan),
plan.schema(),
plan.partition_statistics(None)?,
))
})
.collect::<Result<Vec<_>, DataFusionError>>();
// If any without statistics, return none
let Ok(plans_schema_and_stats) = plans_schema_and_stats else {
return None;
};
// get value range of the sorted column for each input
let mut min_max_ranges = Vec::with_capacity(plans_schema_and_stats.len());
for (input, input_schema, input_stats) in plans_schema_and_stats {
// get index of the sorted column in the schema
let Ok(sorted_col_index) = input_schema.index_of(column_name) else {
// panic that the sorted column is not in the schema
panic!("sorted column {column_name} is not in the schema");
};
let column_stats = input_stats.column_statistics;
let sorted_col_stats = column_stats[sorted_col_index].clone();
match (sorted_col_stats.min_value, sorted_col_stats.max_value) {
(Precision::Exact(min), Precision::Exact(max)) => {
min_max_ranges.push((min, max));
}
// WARNING: this may produce incorrect results until we use more precision
// as `Inexact` is not guaranteed to cover the actual min and max values
// https://github.com/apache/arrow-datafusion/issues/8078
(Precision::Inexact(min), Precision::Inexact(max)) => {
let _deduplicate_exec = input.as_any().downcast_ref::<DeduplicateExec>()?;
min_max_ranges.push((min, max));
}
// the statistics values are absent
_ => return None,
}View on GitHub (pinned to 06200ef96b)