mengdou created CALCITE-5260:
--------------------------------

             Summary: The bindings should properly pop last added RelNode when 
fail to match a subtree
                 Key: CALCITE-5260
                 URL: https://issues.apache.org/jira/browse/CALCITE-5260
             Project: Calcite
          Issue Type: Bug
          Components: core
    Affects Versions: 1.31.0
            Reporter: mengdou
         Attachments: image-2022-09-01-19-34-04-600.png, 
image-2022-09-01-19-36-29-325.png, image-2022-09-01-19-41-48-852.png, 
image-2022-09-01-19-42-08-804.png

First I define a pattern(For demonstration)  like this:
{code:java}
// pattern like this, using 'unordered' child policy for MultiJoin
operandJ(MultiJoin.class, ...
  unordered(
    operand(Project.class, ...
      operand(TableScan.class, ...))))
{code}
Then there is a RelNode tree like this:
{code:java}
MultiJoin
  Project
    Filter  -- matched unsuccessfully and jump out
      TableScan
  Project
    TableScan -- matched successfully{code}
and HepPlanner adds temporary nodes into 'bindings' list when applying a rule 
and trying to match operands:

!image-2022-09-01-19-34-04-600.png!  

When fail to match a subtree, HepPlanner would jump out immediately and try 
other possible subtrees, but DO NOT pop the last added node:

!image-2022-09-01-19-36-29-325.png!

 

If HepPlanner matches a subtree for current rule finally, it will constructs a 
HepRuleCall using bindings as the matched relnodes, which contains unnecessary 
nodes yet

!image-2022-09-01-19-41-48-852.png!

And an assertion in constructor fails  

!image-2022-09-01-19-42-08-804.png!

 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to