osdir.com


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question about complex rule operands and Rel tree in general


Hello everyone!

I have a question that I can't find an answer to, so maybe someone could
help me.
As a part of Rel Rules, there is always an operand, that matches a part of
the tree, and says if the rule should be executed.
The operand can be complex, so I can say for example - match an Aggregate
on top of Project on top of Filter. AFAIU, this operand will only match if
exactly this three nodes will be somewhere in the tree.
But here is my question - what if I want a rule that will match a more
generic structure, like this
>Aggregate
>-...
>--* any number of any nodes in any levels
>---...
>----  Project
Is there an official way to do that?

My first approach was to match any Aggregate and then try to inspect the
underlying tree in matches()/onMatch(), but this turned out to be quite
unreliable since it involves inspecting RelSubsets (and this shouldn't be
done, as follows from
https://lists.apache.org/thread.html/ee2349272e9d344228595c0940820b2fc525cc6115388c48e99495a6@%3Cdev.calcite.apache.org%3E).


In case I'm doing it all wrong, I can formulate my question even broader -
is there a mechanism to perform validation of the execution tree during the
planning process, i.e. skip some plans as unimplementable based on their
internal structure. As an example imagine I want to say that in
JdbcConvention, all plans that have a Filter node, over a Project node that
has more than three fields, should not be implemented. (Modifying cost
calculation is also not an option since the plan still has RelSubsets)

I hope this makes sense, and thanks in advance!

Best Regards,
Andrew Tsvielodub