get_consecutive_window_exprs

Function get_consecutive_window_exprs 

Source
fn get_consecutive_window_exprs(
    window: Window,
) -> (Vec<Vec<Expr>>, Vec<DFSchemaRef>, LogicalPlan)
Expand description

Get all window expressions inside the consecutive window operators.

Returns the window expressions, and the input to the deepest child LogicalPlan.

For example, if the input window looks like

  LogicalPlan::Window(exprs=[a, b, c])
    LogicalPlan::Window(exprs=[d])
      InputPlan

Returns:

  • window_exprs: [[a, b, c], [d]]
  • InputPlan

Consecutive window expressions may refer to same complex expression.

If same complex expression is referred more than once by subsequent WindowAggrs, we can cache complex expression by evaluating it with a projection before the first WindowAggr.

This enables us to cache complex expression “c3+c4” for following plan:

WindowAggr: windowExpr=[[sum(c9) ORDER BY [c3 + c4] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]
--WindowAggr: windowExpr=[[sum(c9) ORDER BY [c3 + c4] RANGE BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW]]

where, it is referred once by each WindowAggr (total of 2) in the plan.