Class SingleValuesOptimizationRules.PruneSingleValueRule

All Implemented Interfaces:
SubstitutionRule, TransformationRule
Enclosing class:
SingleValuesOptimizationRules

protected abstract static class SingleValuesOptimizationRules.PruneSingleValueRule extends RelRule<SingleValuesOptimizationRules.PruneSingleValueRule.Config> implements SubstitutionRule
Abstract class for all the SingleValuesOptimizationRules. All the specific SingleValuesOptimizationRules call the onMatch function to replace a Join with equivalent tree when eligible.
  • Constructor Details

  • Method Details

    • getRexTransformer

      protected BiFunction<RexNode,List<RexNode>,List<RexNode>> getRexTransformer(RexBuilder rexBuilder, JoinRelType joinRelType)
    • onMatch

      protected void onMatch(RelOptRuleCall call, Values values, @Nullable Project project, Join join, RelNode other, boolean isOnLefSide)
      onMatch function contains common optimization logic for all the SingleValueOptimization rules. It simplifies the rel node tree by removing a Join node and creating a required filter as applicable. In case of the LEFT/RIGHT joins, a case expression which produce NULL values for non-matching rows will be created as part of a Project node. The transformation can be illustrated by following e.g. TableScan(Emp) join (cond: Emp.empno = v.no) with Values(1010 as no) → Filter(Emp.empno = 1010) on TableScan(Emp)
      Parameters:
      call - A RelOptRuleCall object
      values - A constant relation node which produces a single row.
      project - A project node which has dynamic constants (can be null).
      join - A join node which will get removed.
      other - A node on the other side of the join (apart from Values)
      isOnLefSide - Whether a Values node is on the Left side or the right side of the Join.
    • autoPruneOld

      public boolean autoPruneOld()
      Description copied from interface: SubstitutionRule
      Whether the planner should automatically prune old node when there is at least 1 equivalent rel generated by the rule.

      Default is false, the user needs to prune the old node manually in the rule.

      Specified by:
      autoPruneOld in interface SubstitutionRule