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:
Piotr Rzysko
2025-09-12 09:17:21 +02:00
parent f5efcbe745
commit 9ff2133ff2

View File

@@ -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(())
}