Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4161

MergeJoin algorithm should not assume inputs sorted in ascending order

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Duplicate
    • 1.24.0
    • None
    • core, linq4j
    • None

    Description

      given a sql:

      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
      

      the final plan is:

       

      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]]) 
      

      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 .

       

       

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              hhlai1990 Lai Zhou
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: