[
https://issues.apache.org/jira/browse/CALCITE-7761?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18110862#comment-18110862
]
Julian Hyde commented on CALCITE-7761:
--------------------------------------
I agree that you have found a bug. Calcite should not rewrite if there are
OFFSET or FETCH clauses.
I am still skeptical that there is no SQL test case. It's a shame that your
test case is much longer than the bug fix. It will need to be maintained.
For the record, handling ROWNUM by rewriting in the validator sounds like a bad
idea. AST rewrites are fragile (e.g. easily capture names). The Rel layer is
the place for rewrites.
> Preserve OFFSET and FETCH when rewriting outer ORDER BY
> -------------------------------------------------------
>
> Key: CALCITE-7761
> URL: https://issues.apache.org/jira/browse/CALCITE-7761
> Project: Calcite
> Issue Type: Improvement
> Reporter: Kirill Tkalenko
> Assignee: Kirill Tkalenko
> Priority: Major
> Labels: pull-request-available
>
> {{SqlValidatorImpl.performUnconditionalRewrites}} may overwrite {{OFFSET}} or
> {{FETCH}} previously added to an inner {{SELECT}} during query rewriting.
> Merge the outer {{SqlOrderBy}} only when the inner {{SELECT}} has no
> {{{}ORDER BY{}}}, {{{}OFFSET{}}}, or {{{}FETCH{}}}.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)