add_projection_on_top_if_helpful

Function add_projection_on_top_if_helpful 

Source
fn add_projection_on_top_if_helpful(
    plan: LogicalPlan,
    project_exprs: Vec<Expr>,
) -> Result<Transformed<LogicalPlan>>
Expand description

Adds a projection on top of a logical plan if doing so reduces the number of columns for the parent operator.

This function takes a LogicalPlan and a list of projection expressions. If the projection is beneficial (it reduces the number of columns in the plan) a new LogicalPlan with the projection is created and returned, along with a true flag. If the projection doesn’t reduce the number of columns, the original plan is returned with a false flag.

§Parameters

  • plan - The input LogicalPlan to potentially add a projection to.
  • project_exprs - A list of expressions for the projection.

§Returns

A Transformed indicating if a projection was added