Thanks, Julian. Since the RelNode in my case is a LocalProject, I tried
below. But I'll switch to what you have suggested.

LogicalProject logicalProject = (LogicalProject) origProj;
List<RexNode> childExps =
logicalProject.getNamedProjects().stream().map(p ->
p.left).collect(Collectors.toList());


On Thu, Feb 3, 2022 at 12:24 AM Julian Hyde <[email protected]> wrote:

> You don’t need to override RexShuttle.apply(List<RexNode>) (and in fact I
> don’t know whether it will be called). Create your own shuttle and override
> the methods for the sub-classes of RexNode that are of interest, e.g. the
> following prints all input refs
>
>   RelNode r;
>   r.accept(
>       new RexShuttle() {
>         @Override RexNode visitInputRef(RexInputRef ref) {
>           System.out.println(“input ref “ + ref);
>         }
>       });
>
> One problem of that approach is that it doesn’t give you the top-level
> expression or expressions, it goes deep.
>
> If you know you are looking at a particular kind of operator (e.g.
> Project, Filter, Join, Sort), call the particular method that returns the
> expressions (Project.getProjects(), Filter.getCondition(), etc.).
>
> Julian
>
>
> > On Feb 2, 2022, at 7:09 AM, Chathura Widanage <
> [email protected]> wrote:
> >
> > Hi,
> >
> > I'm upgrading a set of custom rules from 1.23.0 to the latest. We have a
> > custom rule that uses org.apache.calcite.rel.RelNode#getChildExps and
> seems
> > it's deprecated in latest versions. Although it suggests to use
> >
> org.apache.calcite.rel.RelNode#accept(org.apache.calcite.rex.RexShuttle), I
> > couldn't figureout a way to get a List<RexNode> out since
> > org.apache.calcite.rex.RexShuttle#apply(java.util.List<T>) is final.
> Could
> > you please let me know how I can replace
> > org.apache.calcite.rel.RelNode#getChildExps?
> >
> > Regards,
> > Chathura
>
>

Reply via email to