Hi Danny, Apart from RelShuttle there is also RelVisitor which has a visit method that provides the parent [1]. Not sure, if it suits your needs.
Best, Stamatis [1] https://github.com/apache/calcite/blob/ee83efd360793ef4201f4cdfc2af8d837b76ca69/core/src/main/java/org/apache/calcite/rel/RelVisitor.java#L43 On Mon, Apr 22, 2019 at 2:14 PM Yuzhao Chen <[email protected]> wrote: > Now for RelNode, we have method getInput()[1] to fetch the input > RelNodes, but how we fetch the parent ? > > For example, we have plan: > > join-rel > / \ > scan1 scan2 > > > We can get scan1 and scan2 in join-rel directly with method getInput, but > how can we get the join rel in scan1 and scan 2 ? > > I know that there is a RelShuttle that can visit every RelNode and if I > make a cache for the inputs mapping, finally I can get the ‘parents’ from > the cache, but this is boring code and not that intuitive. > > Do you guys have any good ideas ? > > [1] > https://github.com/apache/calcite/blob/ee83efd360793ef4201f4cdfc2af8d837b76ca69/core/src/main/java/org/apache/calcite/rel/RelNode.java#L132 > > > Best, > Danny Chan >
