You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Jacques Nadeau (JIRA)" <ji...@apache.org> on 2015/08/23 21:49:46 UTC
[jira] [Updated] (CALCITE-737) When being used with Union, Order by
is wrongly associated with the outer query
[ https://issues.apache.org/jira/browse/CALCITE-737?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Jacques Nadeau updated CALCITE-737:
-----------------------------------
Fix Version/s: 1.4.0-incubating
> When being used with Union, Order by is wrongly associated with the outer query
> -------------------------------------------------------------------------------
>
> Key: CALCITE-737
> URL: https://issues.apache.org/jira/browse/CALCITE-737
> Project: Calcite
> Issue Type: Bug
> Reporter: Sean Hsuan-Yi Chu
> Assignee: Julian Hyde
> Fix For: 1.4.0-incubating
>
>
> {code}
> select empno from emp t1 where empno = 1
> union
> select empno from emp t2 where empno is not null
> group by empno
> order by empno
> {code}
> Since union is a set operator, the Order-By is supposed to be associated with the second subquery. However, the Rel Tree generated by Calcite is
> {code}
> LogicalSort(sort0=[$0], dir0=[ASC])
> LogicalProject(EMPNO=[$0])
> LogicalUnion(all=[false])
> LogicalProject(EMPNO=[$0])
> LogicalFilter(condition=[=($0, 1)])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> LogicalAggregate(group=[{0}])
> LogicalProject(EMPNO=[$0])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> {code}
> where LogicalSort is performed at the end.
> Union-All has the same behavior also.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)