Lai Zhou created CALCITE-4161:
---------------------------------

             Summary: 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


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)

Reply via email to