mirror of
https://github.com/aljazceru/turso.git
synced 2025-12-24 11:34:21 +01:00
Rewrite window function expressions in the optimizer
Currently, this is effectively a no-op because, at the optimization stage, window function expressions are in the form win_func(subquery_column1, subquery_column2, ...). Nevertheless, expressions are rewritten to maintain consistency with aggregates, which also hold cloned expressions from sources like result columns. This ensures future changes in the optimizer won’t break window function handling.
This commit is contained in:
@@ -578,6 +578,11 @@ fn rewrite_exprs_select(plan: &mut SelectPlan) -> Result<()> {
|
||||
for (expr, _) in plan.order_by.iter_mut() {
|
||||
rewrite_expr(expr, &mut param_count)?;
|
||||
}
|
||||
if let Some(window) = &mut plan.window {
|
||||
for func in window.functions.iter_mut() {
|
||||
rewrite_expr(&mut func.original_expr, &mut param_count)?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user