[ 
https://issues.apache.org/jira/browse/CALCITE-1498?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15685197#comment-15685197
 ] 

Julian Hyde commented on CALCITE-1498:
--------------------------------------

I guessed it was something like that. Anyway, I wanted to change the abstract 
to something that would be meaningful in the release notes. Feel free to change 
it again.

If they've written {{OFFSET 10 LIMIT 20}} I don't see why you shouldn't push 
that offset + limit to the input of the join. Sure, the query results will be 
non-deterministic, but {{ORDER BY sal OFFSET 10 LIMIT 20}} is non-deterministic 
too, because {{sal}} is not unique.

> Allow LIMIT with trivial ORDER BY to be pushed through JOIN
> -----------------------------------------------------------
>
>                 Key: CALCITE-1498
>                 URL: https://issues.apache.org/jira/browse/CALCITE-1498
>             Project: Calcite
>          Issue Type: Bug
>          Components: core
>    Affects Versions: 1.10.0
>            Reporter: Maryann Xue
>            Assignee: Maryann Xue
>            Priority: Minor
>
> Allow LIMIT with trivial ORDER BY to be pushed through a JOIN that does not 
> affect the number of rows. Currently it cannot, because 
> {{RelMdUtil.checkInputForCollationAndLimit}} does not know that an sort on 
> zero keys is trivially satisfied (without requiring a Sort) by any relational 
> expression:
> {code}
>     // Check if the input is already sorted
>     boolean alreadySorted = false;
>     if (!alreadySorted) {
>       for (RelCollation inputCollation : mq.collations(input)) {
>         if (inputCollation.satisfies(collation)) {
>           alreadySorted = true;
>           break;
>         }
>       }
>     }
> {code}
> if {{mq.collations(input)}} returns an empty array, {{alreadySorted}} will 
> always be false even if the required {{collation}} is an empty collation 
> (which indicates there's no need to sort).



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to