You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Ruben Q L (Jira)" <ji...@apache.org> on 2025/10/12 10:42:00 UTC
[jira] [Resolved] (CALCITE-7222) SortRemoveDuplicateKeysRule miss fetch and offset information
[ https://issues.apache.org/jira/browse/CALCITE-7222?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Ruben Q L resolved CALCITE-7222.
--------------------------------
Resolution: Fixed
Fixed via [{{34ae30c}}|https://github.com/apache/calcite/commit/34ae30c7c6db7cf2172e1dd81a6023e6866ae215]
Thanks [~zwhtx] for reporting and [~jensen] for the patch!
> 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)