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

Julian Hyde commented on CALCITE-4021:
--------------------------------------

{{EnumerableUnion}} COULD preserve ordering but SHOULD it? In order to preserve 
ordering {{EnumerableUnion}} would have to merge. That would imply evaluating 
the inputs in parallel and/or buffering, which might be less desirable in some 
circumstances than what {{EnumerableUnion}} does today - namely a 'cat' 
operation - read input 1 to completion, then read input 2 to completion.

I think we would not want to get rid of what we have today. So, to achieve what 
you want we would implement {{EnumerableMergeUnion}}, which exactly what 
CALCITE-3221 proposes.

> EnumerableUnion should preserve ordering when all inputs have the same 
> collation
> --------------------------------------------------------------------------------
>
>                 Key: CALCITE-4021
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4021
>             Project: Calcite
>          Issue Type: Improvement
>            Reporter: Rui Wang
>            Assignee: Rui Wang
>            Priority: Major
>
> For query:
> {code:sql}
> select name from sales_dept
> union 
> select name from it_dept
> order by mgr
> {code}
> We could generate a plan based on 
> https://issues.apache.org/jira/browse/CALCITE-4017:
> {code:java}
> EnumerableUnion
>     EnumerableProject
>         EnumerableSort
>            EnumerableTableScan[name="sales_dept"]
>     EnumerableProject
>         EnumerableSort
>            EnumerableTableScan[name="it_dept"]
> {code}
> So EnumerableUnion should preserve ordering when all input have the same 
> collation to make sure result of query is correct.



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

Reply via email to