Hi everyone,

I noticed that rules ProjectCalcMergeRule and FilterCalcMergeRule
strictly dependent on LogicalCalc class (e.g. casting call.rel to
LogicalCalc, using LogicalCalc.create method and etc). I suggest
making them more generalized (like CalcMergeRule) and use only
Project, Filter and Calc interfaces, which will expand the range of
their applying.

Concrete:

1. In FilterCalcMergeRule get rid of casting to LogicalCalc and LogicalFilter:

  @Override public void onMatch(RelOptRuleCall call) {
    final Filter filter = call.rel(0);
    final Calc calc = call.rel(1);


2. In FilterCalcMergeRule and FilterCalcMergeRule replace
LogicalCalc.create with calc.copy:

  final Calc newCalc = calc.copy(calc.getTraitSet(), calc.getInput(),
mergedProgram);


3. In ProjectCalcMergeRule replace the code:

    if (RexOver.containsOver(program)) {
      LogicalCalc projectAsCalc = LogicalCalc.create(calc, program);
      call.transformTo(projectAsCalc);
      return;
    }

with a simple one:

    if (RexOver.containsOver(program)) {
      return;
    }

because special rule ProjectToCalcRule convert LogicalProject to LogicalCalc.

Reply via email to