You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@calcite.apache.org by Aitozi <gj...@gmail.com> on 2023/01/09 12:39:40 UTC

How to match the arbitrary number of RelNodes

Hi, community:
  When I write a rule to match a subtree as a union followed by any
number of RelNodes which is not an exchange node (I think this subtree
can transpose before the union nodes), It will help reduce the shuffle
in physical nodes. But there seems to be no suitable API to describe
this greedy pattern match with an arbitrary number of intermediate
nodes. If there is sth I missed, I would appreciate it if anyone could
help point it out.

BTW, I read this ticket, it seems to have similar requirements:

https://issues.apache.org/jira/browse/CALCITE-3761

Thanks
Aitozi.

Re: How to match the arbitrary number of RelNodes

Posted by Chunwei Lei <ch...@gmail.com>.
Hi, Aitozi.

I think you can check RelRule#unorderedInputs[1]. One of its uses is
PruneEmptyRules.

[1]
https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/plan/RelRule.java#L219

Best,
Chunwei


On Tue, Jan 10, 2023 at 12:32 AM Ruben Q L <ru...@gmail.com> wrote:

> Hello Aitozi,
>
> Could you please provide one or several examples of a plan that your rule
> aims to match? (as it was done in
> https://issues.apache.org/jira/browse/CALCITE-3761)
> Maybe you could use RelRule#OperandDetailBuilder#predicate [1] and write
> your (more-or-less-complex) predicate function for the rule operand(s)?
>
> Best,
> Ruben
>
> [1]
>
> https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/plan/RelRule.java#L210
>
>
>
> On Mon, Jan 9, 2023 at 12:40 PM Aitozi <gj...@gmail.com> wrote:
>
> > Hi, community:
> >   When I write a rule to match a subtree as a union followed by any
> > number of RelNodes which is not an exchange node (I think this subtree
> > can transpose before the union nodes), It will help reduce the shuffle
> > in physical nodes. But there seems to be no suitable API to describe
> > this greedy pattern match with an arbitrary number of intermediate
> > nodes. If there is sth I missed, I would appreciate it if anyone could
> > help point it out.
> >
> > BTW, I read this ticket, it seems to have similar requirements:
> >
> > https://issues.apache.org/jira/browse/CALCITE-3761
> >
> > Thanks
> > Aitozi.
> >
>

Re: How to match the arbitrary number of RelNodes

Posted by Ruben Q L <ru...@gmail.com>.
Hello Aitozi,

Could you please provide one or several examples of a plan that your rule
aims to match? (as it was done in
https://issues.apache.org/jira/browse/CALCITE-3761)
Maybe you could use RelRule#OperandDetailBuilder#predicate [1] and write
your (more-or-less-complex) predicate function for the rule operand(s)?

Best,
Ruben

[1]
https://github.com/apache/calcite/blob/main/core/src/main/java/org/apache/calcite/plan/RelRule.java#L210



On Mon, Jan 9, 2023 at 12:40 PM Aitozi <gj...@gmail.com> wrote:

> Hi, community:
>   When I write a rule to match a subtree as a union followed by any
> number of RelNodes which is not an exchange node (I think this subtree
> can transpose before the union nodes), It will help reduce the shuffle
> in physical nodes. But there seems to be no suitable API to describe
> this greedy pattern match with an arbitrary number of intermediate
> nodes. If there is sth I missed, I would appreciate it if anyone could
> help point it out.
>
> BTW, I read this ticket, it seems to have similar requirements:
>
> https://issues.apache.org/jira/browse/CALCITE-3761
>
> Thanks
> Aitozi.
>