Skip to content

Commit 6b006e5

Browse files
committed
fix: Rebase window exprs: Physical plan does not support logical expression SUM(x) PARTITION BY
1 parent a29e681 commit 6b006e5

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

datafusion/core/src/sql/planner.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,10 +1167,17 @@ impl<'a, S: ContextProvider> SqlToRel<'a, S> {
11671167
// process window function
11681168
let window_func_exprs = find_window_exprs(&select_exprs_post_aggr);
11691169

1170-
let plan = if window_func_exprs.is_empty() {
1171-
plan
1170+
let (plan, select_exprs_post_aggr) = if window_func_exprs.is_empty() {
1171+
(plan, select_exprs_post_aggr)
11721172
} else {
1173-
LogicalPlanBuilder::window_plan(plan, window_func_exprs)?
1173+
let select_exprs_post_aggr_and_window = select_exprs_post_aggr
1174+
.iter()
1175+
.map(|expr| rebase_expr(expr, &window_func_exprs, &plan))
1176+
.collect::<Result<Vec<Expr>>>()?;
1177+
(
1178+
LogicalPlanBuilder::window_plan(plan, window_func_exprs)?,
1179+
select_exprs_post_aggr_and_window,
1180+
)
11741181
};
11751182

11761183
// final projection

0 commit comments

Comments
 (0)