[ 
https://issues.apache.org/jira/browse/CALCITE-1098?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15156132#comment-15156132
 ] 

Julian Hyde commented on CALCITE-1098:
--------------------------------------

Does the cycle cause any ill-effects (e.g. an exception)?

We know that firing rules causes cycles sometimes. One example is if you have 
an identity project because two projects permute columns and cancel each other 
out. CALCITE-794 made the statistics system safe when these cycles exist. 
CALCITE-790 would try to remove cycles when it finds them (for some common 
cases) but would not guarantee that cycles occur. But even when these issues 
are fixed, it is a fact of life that a RelNode graph will contain cycles, and 
any code on that graph has to deal with it.

> Set Mergence trigger relNode cyclical reference (ProjectMergeRule)
> ------------------------------------------------------------------
>
>                 Key: CALCITE-1098
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1098
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Jane Lian
>            Assignee: Julian Hyde
>         Attachments: projectMergeTest.patch
>
>
> The issue is found in applying ProjectMergeRule. Following is the case which 
> triggers the relNode's cyclical reference.
> For instance suppose you have following set tree:
> {code}
> Set#2: Project
>   rel#3:Subset#2.NONE
>      rel#4: (‘a’) with input (rel#5:Subset#1.NONE)
> Set#1: Project
>   rel#5:Subset#1.NONE
>      rel#6: (‘a’) with input (rel#7:Subset#0.NONE)
> Set#0: TableScan
>   rel#7:Subset#0.NONE
>      rel#8:Dept
> {code}
> Project#2- Project#1 triggers the ProjectMerge Rule, then a new equivalent 
> Project will be generated, such as, 
> rel#9: (‘a’) with input (rel#7:Subset#0.NONE).
> When the planner is registering rel#9,  it will try to find the equivalent 
> relNode which is reserved in mapDigestToRel. In the above case, rel#6 would 
> be found. The set#2 and set#1 would be merged, then the following is the set 
> tree after mergence:
> {code}
> Set#1: Project
>    rel#5:Subset#1.NONE
>      rel#4: (‘a’) with input (rel#5:Subset#1.NONE)
>      rel#6: (‘a’) with input (rel#7:Subset#0.NONE)
> Set#0: TableScan
>    rel#7:Subset#0.NONE
>      rel#8: Dept
> {code}
> rel#4's input is set#1, then there is a cyclical reference.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to