Class MinusToDistinctRule

All Implemented Interfaces:
TransformationRule

@Enclosing public class MinusToDistinctRule extends RelRule<MinusToDistinctRule.Config> implements TransformationRule
Planner rule that translates a distinct Minus (all = false) into a group of operators composed of Union, Aggregate, Filter,etc.

For example, the query plan


  LogicalMinus(all=[false])
    LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2])
      LogicalFilter(condition=[=($7, 10)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
    LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2])
      LogicalFilter(condition=[=($7, 20)])
        LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 

will convert to


  LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2])
    LogicalFilter(condition=[AND(>($3, 0), =($4, 0))])
      LogicalAggregate(group=[{0, 1, 2}], agg#0=[COUNT() FILTER $3], agg#1=[COUNT() FILTER $4])
        LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], $f3=[=($3, 0)], $f4=[=($3, 1)])
          LogicalUnion(all=[true])
            LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], $f3=[0])
              LogicalFilter(condition=[=($7, 10)])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
            LogicalProject(EMPNO=[$0], ENAME=[$1], JOB=[$2], $f3=[1])
              LogicalFilter(condition=[=($7, 20)])
                LogicalTableScan(table=[[CATALOG, SALES, EMP]])
 
See Also: