Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4936

Generalize FilterCalcMergeRule/ProjectCalcMergeRule to accept any Filter/Project/Calc operator

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.28.0
    • 1.31.0
    • core

    Description

      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.

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              mgramin Maksim Gramin
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 1h 40m
                  1h 40m