You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2020/08/06 16:12:00 UTC

[jira] [Commented] (CALCITE-4161) MergeJoin algorithm should not assume inputs sorted in ascending order

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

Julian Hyde commented on CALCITE-4161:
--------------------------------------

The inputs need to be sorted in the same order. I agree that it doesn't need to be ascending; it could be descending (but not clustered). If the key is composite, the keys could be combination of ascending and descending, as long as the inputs match.

> MergeJoin algorithm should not assume inputs sorted in ascending order
> ----------------------------------------------------------------------
>
>                 Key: CALCITE-4161
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4161
>             Project: Calcite
>          Issue Type: Bug
>          Components: core, linq4j
>    Affects Versions: 1.24.0
>            Reporter: Lai Zhou
>            Priority: Major
>
> given a sql:
> {code:java}
> select id,first_name,vs.specialty_id from vets join vet_specialties vs on vets.id = vs.vet_id and vet_id>1 order by id desc limit 100
> {code}
> the final plan is:
>  
> {code:java}
> EnumerableCalc(expr#0..3=[{inputs}], proj#0..1=[{exprs}], specialty_id=[$t3]) EnumerableLimit(fetch=[100]) EnumerableMergeJoin(condition=[=($0, $2)], joinType=[inner]) EnumerableSort(sort0=[$0], dir0=[DESC]) EnumerableCalc(expr#0..2=[{inputs}], proj#0..1=[{exprs}]) JdbcToEnumerableConverter JdbcFilter(condition=[>($0, 1)]) JdbcTableScan(table=[[default, vets]]) EnumerableSort(sort0=[$0], dir0=[DESC]) JdbcToEnumerableConverter JdbcFilter(condition=[>($0, 1)]) JdbcTableScan(table=[[default, vet_specialties]]) 
> {code}
> The inputs of EnumerableMergeJoin is sorted in descending order,
> but the MergeJoinEnumerator just supports inputs sorted in ascending order,
> the result is wrong.
>  
> I think the MergeJoin should not assume inputs sorted in ascending order,
> it should know the inputs sorted order .
>  
>  



--
This message was sent by Atlassian Jira
(v8.3.4#803005)