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

Sean Hsuan-Yi Chu commented on CALCITE-900:
-------------------------------------------

The motivation is that we found out infinite planning on DRILL side 
(unfortunately, I have not been able to reproduce on Calcite). For this query 
{code}
WITH year_total 
             AS (SELECT c.r_regionkey    customer_id,
                        1 year_total
                 FROM   table c
                 UNION ALL 
                 SELECT c.r_regionkey    customer_id, 
                        1 year_total
                 FROM   table c)
        SELECT t_w_firstyear.customer_id
        FROM   year_total t_w_firstyear,
               year_total t_w_secyear
        WHERE  t_w_firstyear.year_total = t_w_secyear.year_total
         AND t_w_firstyear.year_total > 0 and t_w_secyear.year_total > 0
{code}

According to the trace, ProjectSetOpTransposeRule and FilterSetOpTransposeRule 
run into a loop, where one generates new plan triggering the other one. 
Basically, I was trying to find a place to cut the loop. 

Let me show the trace in the attachment and explain what is happening in the 
planning below:

rel#217 in SubSet#2 keeps triggering FilterSetOpTransposeRule and add new Rels 
into SubSet#2 (who is the input of rel#126); 

On the other hand, rel#126 in SubSet#11 keeps triggering 
ProjectSetOpTransposeRule and add new Set (that means if you let planner keep 
going, you would see more sets get added)





> ProjectSetOpTransposeRule can be improved when the input is a SetOperator 
> with Trivial Project on top
> -----------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-900
>                 URL: https://issues.apache.org/jira/browse/CALCITE-900
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Sean Hsuan-Yi Chu
>            Assignee: Julian Hyde
>
> When SetOperator with Trivial Project on top, pushing this trivial project 
> does not necessary. An improvement can be done if we just discard this 
> trivial project. 



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

Reply via email to