[ https://issues.apache.org/jira/browse/CALCITE-5166?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Roman Kondakov updated CALCITE-5166: ------------------------------------ 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: {code:java} @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)); } {code} was: 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: {code:java} @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; } }; visitor.visit(calc); assertThat(rels.size(), is(1)); assertThat(rels.get(0), isA(LogicalCalc.class)); } {code} > Method accept(RelShuttle) is not overridden in LogicalCalc and > LogicalTableModify > --------------------------------------------------------------------------------- > > Key: CALCITE-5166 > URL: https://issues.apache.org/jira/browse/CALCITE-5166 > Project: Calcite > Issue Type: Bug > Components: core > Affects Versions: 1.30.0 > Reporter: Roman Kondakov > Assignee: Roman Kondakov > Priority: Major > Fix For: 1.31.0 > > > 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: > {code:java} > @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)); > } {code} -- This message was sent by Atlassian Jira (v8.20.7#820007)