Class UnaliasSymbolReferences

java.lang.Object
io.trino.sql.planner.optimizations.UnaliasSymbolReferences
All Implemented Interfaces:
PlanOptimizer

public class UnaliasSymbolReferences extends Object implements PlanOptimizer
Re-maps symbol references that are just aliases of each other (e.g., due to projections like $0 := $1)

E.g.,

Output[$0, $1] -> Project[$0 := $2, $1 := $3 * 100] -> Aggregate[$2, $3 := sum($4)] -> ...

gets rewritten as

Output[$2, $1] -> Project[$2, $1 := $3 * 100] -> Aggregate[$2, $3 := sum($4)] -> ...

  • Constructor Details

    • UnaliasSymbolReferences

      public UnaliasSymbolReferences(Metadata metadata)
  • Method Details

    • optimize

      public PlanNode optimize(PlanNode plan, PlanOptimizer.Context context)
      Specified by:
      optimize in interface PlanOptimizer
    • reallocateSymbols

      public NodeAndMappings reallocateSymbols(PlanNode plan, List<Symbol> fields, SymbolAllocator symbolAllocator)
      Replace all symbols in the plan with new symbols. The returned plan has different output than the original plan. Also, the order of symbols might change during symbol replacement. Symbols in the list `fields` are replaced maintaining the order so they might be used to match original symbols with their replacements. Replacing symbols helps avoid collisions when symbols or parts of the plan are reused.