[
https://issues.apache.org/jira/browse/CALCITE-7222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Zhen Chen updated CALCITE-7222:
-------------------------------
Description:
The current issue is that the FETCH and OFFSET are lost in the SORT after this
rule transformation. I mistakenly used relBuilder.sort when generating the
new SORT—it should have been relBuilder.sortLimit .
The test case is
{code:java}
</TestCase>
<TestCase name="testSortRemoveDuplicateKeysWithLimit">
<Resource name="sql">
<![CDATA[select * from (select empno as a, empno as b from emp) t order
by a, b limit 1 offset 2]]>
</Resource>
<Resource name="planBefore">
<![CDATA[
LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], offset=[2],
fetch=[1])
LogicalProject(A=[$0], B=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planAfter">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC]) <--- here missing offset and fetch
LogicalProject(A=[$0], B=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
{code}
was:
The current issue is that the FETCH and OFFSET are lost in the SORT after this
rule transformation. I mistakenly used relBuilder.sort when generating the
new SORT—it should have been relBuilder.sortLimit .
The test case is
{code:java}
</TestCase>
<TestCase name="testSortRemoveDuplicateKeysWithLimit">
<Resource name="sql">
<![CDATA[select * from (select empno as a, empno as b from emp) t order
by a, b limit 1 offset 2]]>
</Resource>
<Resource name="planBefore">
<![CDATA[
LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], offset=[2],
fetch=[1])
LogicalProject(A=[$0], B=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
<Resource name="planAfter">
<![CDATA[
LogicalSort(sort0=[$0], dir0=[ASC]) *<--- here missing offset and fetch*
LogicalProject(A=[$0], B=[$0])
LogicalTableScan(table=[[CATALOG, SALES, EMP]])
]]>
</Resource>
</TestCase>
{code}
> SortRemoveDuplicateKeysRule miss fetch and offset information
> -------------------------------------------------------------
>
> Key: CALCITE-7222
> URL: https://issues.apache.org/jira/browse/CALCITE-7222
> Project: Calcite
> Issue Type: Bug
> Reporter: weihua zhang
> Assignee: Zhen Chen
> Priority: Major
> Labels: pull-request-available
> Fix For: 1.41.0
>
>
> The current issue is that the FETCH and OFFSET are lost in the SORT after
> this rule transformation. I mistakenly used relBuilder.sort when generating
> the new SORT—it should have been relBuilder.sortLimit .
> The test case is
> {code:java}
> </TestCase>
> <TestCase name="testSortRemoveDuplicateKeysWithLimit">
> <Resource name="sql">
> <![CDATA[select * from (select empno as a, empno as b from emp) t order
> by a, b limit 1 offset 2]]>
> </Resource>
> <Resource name="planBefore">
> <![CDATA[
> LogicalSort(sort0=[$0], sort1=[$1], dir0=[ASC], dir1=[ASC], offset=[2],
> fetch=[1])
> LogicalProject(A=[$0], B=[$0])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
> </Resource>
> <Resource name="planAfter">
> <![CDATA[
> LogicalSort(sort0=[$0], dir0=[ASC]) <--- here missing offset and fetch
> LogicalProject(A=[$0], B=[$0])
> LogicalTableScan(table=[[CATALOG, SALES, EMP]])
> ]]>
> </Resource>
> </TestCase>
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)