You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Γιώργος Θεοδωράκης <gi...@gmail.com> on 2016/09/29 12:17:04 UTC

Creating a RelNode list from a logical Plan

Hello,
I have a logical plan as RelNode, and I want to break it into single
operators and get a list of RelNodes. With RelNode.getInputs() I get every
node except the parent. How do I get the parent node? For example, I have

LogicalProject(orderid=[$0], productid=[$1], units=[$2])
  LogicalFilter(condition=[AND(>($2, 5), >(1, 4), =(3, 4))])
    LogicalTableScan(table=[[s, orders]])

and I can't get the LogicalProject Node.

Thanks,
George

Re: Creating a RelNode list from a logical Plan

Posted by Julian Hyde <jh...@apache.org>.
Ah, it’s by design that a RelNode can’t find its parent. Why? Because it may have lots of parents!

VolcanoPlanner uses dynamic programming, so a given RelNode, r, may be used several times in the same query. Each of RelNode that has r as an input is “a parent”.

VolcanoPlanner also provides the solution: define a rule that matches a pattern. In this case, define a rule that looks for a Project on top of a Filter on top of a TableScan. The planner will find every occurrence of that pattern in the graph, and fire the rule. It also notices when new additions to the graph cause the rule to be matched.

Julian





> On Sep 29, 2016, at 5:17 AM, Γιώργος Θεοδωράκης <gi...@gmail.com> wrote:
> 
> Hello,
> I have a logical plan as RelNode, and I want to break it into single
> operators and get a list of RelNodes. With RelNode.getInputs() I get every
> node except the parent. How do I get the parent node? For example, I have
> 
> LogicalProject(orderid=[$0], productid=[$1], units=[$2])
>  LogicalFilter(condition=[AND(>($2, 5), >(1, 4), =(3, 4))])
>    LogicalTableScan(table=[[s, orders]])
> 
> and I can't get the LogicalProject Node.
> 
> Thanks,
> George