Hi Ian,

Is there any specific reason or use case that you have to match the root node 
and find the parent node in your customized rule?

Thanks,
Haisheng Yuan

On 2021/05/03 20:20:22, Julian Hyde <jh...@apache.org> wrote: 
> > Is there a way to identify a node as being a root node during RelRule.match?
> 
> Not currently. One workaround would be to create 'class MyRoot extends
> SingleRel', add it as the root of the tree, and write your rules to
> match on it.
> 
> > Or more generally, is there a way to collect the parents of an arbitrary 
> > RelNode?
> 
> By design, the only way to find the parents of a RelNode are to write
> a rule that matches those parents. This ensures that rules will work
> in the Volcano planner, where a RelNode can have many parents.
> 
> Julian
> 
> On Mon, May 3, 2021 at 12:52 PM Ian Bertolacci
> <ian.bertola...@workday.com.invalid> wrote:
> >
> > Hello,
> > I am trying to write a rule that matches (among other things) the root of a 
> > RelNode tree.
> >
> > Unfortunately, it seems that HepRuleCall.parents is only initialized and 
> > populated if the rule extends CommonRelSubExpr, which doesn’t really apply 
> > in my case.
> > (see: 
> > https://github.com/apache/calcite/blob/master/core/src/main/java/org/apache/calcite/plan/hep/HepPlanner.java#L526)
> >
> > Is there a way to identify a node as being a root node during 
> > RelRule.match? Or more generally, is there a way to collect the parents of 
> > an arbitrary RelNode?
> >
> > Thanks.
> 

Reply via email to