[ https://issues.apache.org/jira/browse/CALCITE-6128?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Sergey Nuyanzin closed CALCITE-6128. ------------------------------------ Resolved in release 1.37.0 (2024-05-06) > RelBuilder.limit should apply offset and fetch to previous Sort operator, if > possible > ------------------------------------------------------------------------------------- > > Key: CALCITE-6128 > URL: https://issues.apache.org/jira/browse/CALCITE-6128 > Project: Calcite > Issue Type: Improvement > Reporter: Julian Hyde > Assignee: Julian Hyde > Priority: Major > Labels: pull-request-available > Fix For: 1.37.0 > > > The {{RelBuilder.limit(offset, fetch)}} method should apply {{offset}} and > {{fetch}} to the previous {{Sort}} operator, if possible. If I call > {{RelBuilder.sortLimit}} to create a {{Sort}} with an offset but no fetch, > then call {{RelBuilder.limit(0, fetch)}} to set a fetch, it currently creates > two {{LogicalSort}} nodes but should just modify the {{fetch}} of the > existing {{{}LogicalSort{}}}. > For example, > {code:java} > b.scan("EMP") > .sortLimit(2, -1, b.field("DEPTNO")) > .limit(-1, 3) > .build() > {code} > should generate the plan > {noformat} > LogicalSort(sort0=[$7], dir0=[ASC], offset=[2], fetch=[3]) > LogicalTableScan(table=[[scott, EMP]]) > {noformat} > but instead generates > {noformat} > LogicalSort(fetch=[3]) > LogicalSort(sort0=[$7], dir0=[ASC], offset=[2]) > LogicalTableScan(table=[[scott, EMP]]) > {noformat} > Similarly any other {{RelBuilder}} methods that allow creating a {{Sort}} > with or without {{offset}} and {{fetch}}. -- This message was sent by Atlassian Jira (v8.20.10#820010)