Class PruneApplyColumns

java.lang.Object
io.trino.sql.planner.iterative.rule.ProjectOffPushDownRule<ApplyNode>
io.trino.sql.planner.iterative.rule.PruneApplyColumns
All Implemented Interfaces:
Rule<ProjectNode>

public class PruneApplyColumns extends ProjectOffPushDownRule<ApplyNode>
This rule restricts the outputs of ApplyNode's input and subquery based on which ApplyNode's output symbols are referenced.

A symbol from input source can be pruned, when - it is not a referenced output symbol - it is not a correlation symbol - it is not referenced in subqueryAssignments

A symbol from subquery source can be pruned, when it is not referenced in subqueryAssignments.

A subquery assignment can be removed, when its key is not a referenced output symbol.

Note: this rule does not remove any symbols from the correlation list. This is responsibility of PruneApplyCorrelation rule.

Transforms:

 - Project (i1, r1)
      - Apply
          correlation: [corr]
          assignments:
              r1 -> a in s1,
              r2 -> b in s2,
          - Input (a, b, corr)
          - Subquery (s1, s2)
 
Into:
 - Project (i1, r1)
      - Apply
          correlation: [corr]
          assignments:
              r1 -> a in s1,
          - Project (a, corr)
              - Input (a, b, corr)
          - Project (s1)
              - Subquery (s1, s2)