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

Method accept(RelShuttle) is not overridden in LogicalCalc and LogicalTableModify

    XMLWordPrintableJSON

Details

    Description

      Method RelNode#accept(RelShuttle) is not overridden for LogicalCalc and LogicalTableModify. This leads to the bug when logic implemented in RelShuttle#visit(LogicalCalc) is never applied because visit() method is never called due to incorrect dispatching.

      This test will fail without accept(RelShuttle) method is overridden in Calc:

      @Test void testRelShuttleForLogicalCalc() {
        final String sql = "select ename from emp";
        final RelNode rel = sql(sql).toRel();
        final HepProgramBuilder programBuilder = HepProgram.builder();
        programBuilder.addRuleInstance(CoreRules.PROJECT_TO_CALC);
        final HepPlanner planner = new HepPlanner(programBuilder.build());
        planner.setRoot(rel);
        final RelNode calc = planner.findBestExp();
        final List<RelNode> rels = new ArrayList<>();
        final RelShuttleImpl visitor = new RelShuttleImpl() {
          @Override public RelNode visit(LogicalCalc calc) {
            RelNode visitedRel = super.visit(calc);
            rels.add(visitedRel);
            return visitedRel;
          }
        };
        calc.accept(visitor);
        assertThat(rels.size(), is(1));
        assertThat(rels.get(0), isA(LogicalCalc.class));
      } 

      Attachments

        Issue Links

          Activity

            People

              rkondakov Roman Kondakov
              rkondakov Roman Kondakov
              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
                  1h