Question about complex rule operands and Rel tree in general
I have a question that I can't find an answer to, so maybe someone could
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
>--* any number of any nodes in any levels
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
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!