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

Rui Wang edited comment on CALCITE-4017 at 5/21/20, 8:49 PM:
-------------------------------------------------------------

I am trying to hack this Jira base on changes from #1985 locally.

>From what I can tell, I am thinking current top-down opt cannot replace 
>SortUnionTransposeRule completely. Push downing a Sort with limit and offset 
>will also need to consider row count, and in some cases, not only the ordering 
>requirement, but limit and offset can be push down.  Top-down opt only 
>consider ordering requirement.


But apparently, if there is no limit/offset, SortUnionTransposeRule will be 
useless, for example, in this query:
{code:sql}
select a.name from dept a 
        union all 
        select b.name from dept b
        order by name;
{code}

Both approach will be able to generate:

{code:java}
        EnumerableUnion(all=[true])
             EnumerableSort(sort0=[$0], dir0=[ASC])
                   EnumerableProject(NAME=[$1])
                           EnumerableTableScan(table=[[CATALOG, SALES, DEPT]])
             EnumerableSort(sort0=[$0], dir0=[ASC])
                   EnumerableProject(NAME=[$1])
                           EnumerableTableScan(table=[[CATALOG, SALES, DEPT]])
{code}




was (Author: amaliujia):
I am trying to hack this Jira base on changes from #1985 locally.

>From what I can tell, I am thinking current top-down opt cannot replace 
>SortUnionTransposeRule completely. Push downing a Sort with limit and offset 
>will also need to consider row count, and in some cases, not only the ordering 
>requirement, but limit and offset can be push down.  Top-down opt only 
>consider ordering requirement.


But apparently, if there is no limit/offset, SortUnionTransposeRule will be 
useless, for example, in this query:
{code:sql}
select a.name from dept a 
        union all 
        select b.name from dept b
        order by name;
{code}


{code:java}
Both approach will be able to generate:
        EnumerableUnion(all=[true])
             EnumerableSort(sort0=[$0], dir0=[ASC])
                   EnumerableProject(NAME=[$1])
                           EnumerableTableScan(table=[[CATALOG, SALES, DEPT]])
             EnumerableSort(sort0=[$0], dir0=[ASC])
                   EnumerableProject(NAME=[$1])
                           EnumerableTableScan(table=[[CATALOG, SALES, DEPT]])
{code}



> Implement trait propagation for Enumerable Setop 
> -------------------------------------------------
>
>                 Key: CALCITE-4017
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4017
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Haisheng Yuan
>            Priority: Major
>
> Mainly for Union operator, not sure about Minus and Intersect. I haven't 
> check how is Enumerable Minus, Intersect's executor implemented.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to