Expand description
OptimizeProjections identifies and eliminates unused columns
Modulesยง
- required_
indices ๐ RequiredIndiceshelper for OptimizeProjection
Structsยง
- Optimize
Projections - Optimizer rule to prune unnecessary columns from intermediate schemas
inside the
LogicalPlan. This rule:
Functionsยง
- add_
projection_ ๐on_ top_ if_ helpful - Adds a projection on top of a logical plan if doing so reduces the number of columns for the parent operator.
- expr_
contains_ ๐subquery - is_
expr_ ๐trivial - is_
projection_ unnecessary - Projection is unnecessary, when
- merge_
consecutive_ ๐projections - Merges consecutive projections.
- optimize_
projections ๐ - Removes unnecessary columns (e.g. columns that do not appear in the output schema and/or are not used during any computation step such as expression evaluation) from the logical plan and its inputs.
- outer_
columns ๐ - Accumulates outer-referenced columns by the
given expression,
expr. - outer_
columns_ ๐helper_ multi - A recursive subroutine that accumulates outer-referenced columns by the
given expressions (
exprs). - plan_
contains_ ๐other_ subqueries - Returns true if the plan subtree contains any subqueries that are not the
CTE reference itself. This treats any non-CTE
LogicalPlan::SubqueryAliasnode (including aliased relations) as a blocker, along with expression-level subqueries like scalar, EXISTS, or IN. These cases prevent projection pushdown for now because we cannot safely reason about their column usage. - rewrite_
expr ๐ - Rewrites a projection expression using the projection before it (i.e. its input)
This is a subroutine to the
merge_consecutive_projectionsfunction. - rewrite_
projection_ ๐given_ requirements - Rewrite the given projection according to the fields required by its ancestors.
- split_
join_ ๐requirements - Splits requirement indices for a join into left and right children based on the join type.
- subquery_
alias_ ๐targets_ recursive_ cte