[ 
https://issues.apache.org/jira/browse/CALCITE-5166?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17540890#comment-17540890
 ] 

Roman Kondakov commented on CALCITE-5166:
-----------------------------------------

Right now, as I can see, there are several logical operators that have no 
overloaded methods in {{{}RelShuttle{}}}. 
 * LogicalWindow
 * LogicalTableSpool
 * LogicalTableFunctionScan
 * LogicalSortExchange
 * LogicalSnapshot
 * LogicalRepeatUnion

There was a [discussion|https://issues.apache.org/jira/browse/CALCITE-4386] 
about whether we need to add new nodes to {{{}RelShuttle{}}}, but there is no 
conclusion there.

My personal opinion is that usually, people create their own extensions of 
{{RelShuttle}} for use in downstream projects.  And that's why we don't need to 
add all Logical nodes to {{RelShuttle}} until they are needed for internal 
Calcite usage. But it's not a strong opinion. Maybe we need to add support for 
{{LogicalWindow}} since it seems a more widely used operator than others.

 

> 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
>              Labels: pull-request-available, pull_request_available
>             Fix For: 1.31.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to