[
https://issues.apache.org/jira/browse/CALCITE-3664?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17006839#comment-17006839
]
Wang Yanlin commented on CALCITE-3664:
--------------------------------------
hi, [[email protected]], thanks for explanation.
I haven't digged into the code, but I added more test, like this
{code:java}
@Test public void testSortInSubquery() {
// final String sql = "select ename from (select ename from emp order by
deptno, ename) a";
// final String sql = "select ename from (select ename from emp order by
ename, deptno) a";
// final String sql = "select ename from (select ename from emp order by
job, deptno) a";
// final String sql = "select ename from (select ename from emp order by
job, ename, deptno) a";
final String sql = "select ename from (select ename from emp order by job,
ename, deptno) a";
sql(sql).ok();
}
{code}
All of them got the same relnode, how can the collation of emp satisfy all of
these orders?
> Sort in subquery is lost when converting SqlNode to Relnode
> -----------------------------------------------------------
>
> Key: CALCITE-3664
> URL: https://issues.apache.org/jira/browse/CALCITE-3664
> Project: Calcite
> Issue Type: Bug
> Reporter: Wang Yanlin
> Assignee: Wang Yanlin
> Priority: Major
>
> Lost sort in subquery when converting a SqlNode to Relnode, making its
> semantics changed.
> The test case to reproduce
> {code:java}
> // SqlToRelConverterTest
> @Test public void testSortInSubquery() {
> final String sql = "select ename from (select ename from emp order by
> ename) a";
> sql(sql).ok();
> }
> {code}
> This test case will success with this plan.
> {code:java}
> <TestCase name="testSortInSubquery">
> <Resource name="sql">
> <![CDATA[select ename from (select ename from emp order by ename)
> a]]>
> </Resource>
> <Resource name="plan">
> <![CDATA[
> LogicalProject(ENAME=[$1])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
> </Resource>
> </TestCase>
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)