databendlabs/databend · error
not implemented
Error message
not implemented
What it means
Panic from `unimplemented!()` in `Sort::replace_column` (src/query/sql/src/planner/plans/sort.rs:70). When rewriting column references in a sort plan, the case where the sort has a window partition is not handled, so the optimizer pass panics with 'not implemented' instead of remapping those columns.
Solutions
- Avoid triggering the rewrite path for plans containing window partitions until supported (or gate the rewrite upstream).
- Extend `replace_column` to iterate and remap `window_partition` expressions with the same closure used for `items`.
- File/track a Databend issue; replace `unimplemented!()` with a proper internal error for a non-panicking failure.
- Reproduce with a minimal ORDER BY + OVER (PARTITION BY) query and include it in the bug report.
Example fix
// before
if self.window_partition.is_some() {
unimplemented!()
};
// after
if let Some(partition) = self.window_partition.as_mut() {
for expr in &mut partition.expressions {
*expr = replace_column_in_expr(expr, &mut replace)?;
}
} Defensive patterns
Strategy: try-catch
Validate before calling
// guard before applying rewrite
fn sort_has_window_partition(sort: &Sort) -> bool { sort.window_partition.is_some() } Type guard
fn can_rewrite_sort(sort: &Sort) -> bool {
sort.window_partition.is_none()
} Try / catch
match sort.replace_column(old, new) {
Ok(()) => {},
Err(e) => return Err(e),
// a panic! here means window_partition is Some; catch_unwind or pre-check
} Prevention
- Check window_partition before running column rewrites on Sort plans
- Add tests covering ORDER BY + OVER (PARTITION BY) to rewrite passes
- Prefer extending the rewrite to window partitions over skipping silently
- Convert unimplemented!() to planner errors in local builds to fail fast
When it happens
Trigger: An optimizer rewrite calls `replace_column` on a `Sort` plan whose `window_partition` is `Some`, e.g. when substituting column indices in a query containing window functions (OVER PARTITION BY) under a sort node.
Common situations: Queries mixing ORDER BY with window functions during plan normalization/scalar substitution; development-time hits when extending expression rewrites to window plans.
Related errors
- internal error: entered unreachable code
- internal error: entered unreachable code
- not implemented
- logic error: expected CreateTable plan
- Input plan must be Query, but it's
AI-assisted analysis of databendlabs/databend@288d84d76e (2026-09-11).
Data as JSON: /api/errors/bfdc60bbce651d53.
Report an issue: GitHub.
Appendix: source
Thrown at src/query/sql/src/planner/plans/sort.rs:70
}
pub fn replace_column(&mut self, old: Symbol, new: Symbol) {
for item in &mut self.items {
if item.index == old {
item.index = new
}
}
if let Some(projection) = &mut self.pre_projection {
for i in projection {
if *i == old {
*i = new
}
}
}
if self.window_partition.is_some() {
unimplemented!()
};
}
pub fn replace_columns<F>(&mut self, mut replace: F) -> Result<()>
where F: FnMut(Symbol) -> Result<Symbol> {
for item in &mut self.items {
item.index = replace(item.index)?;
}
if let Some(projection) = &mut self.pre_projection {
for index in projection {
*index = replace(*index)?;
}
}
if self.window_partition.is_some() {
unimplemented!()
};View on GitHub (pinned to 288d84d76e)