Uploaded image for project: 'Kylin'
  1. Kylin
  2. KYLIN-5830

When the query connects two or more tables, the query results are inconsistent whether the order by field is in the select field or not

    XMLWordPrintableJSON

Details

    • New Feature
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 5.0-beta
    • 5.0.0
    • Query Engine
    • None

    Description

      Q1:

      select CUSTOMER.C_PHONE
      -- ,LO_PARTKEY
      from SSB.CUSTOMER left join SSB.LINEORDER on CUSTOMER.C_CUSTKEY=LINEORDER.LO_CUSTKEY
      order by LINEORDER.LO_PARTKEY NULLS LAST
      LIMIT 500

      Calcite Plan:

      KapProjectRel(C_PHONE=[$6], ctx=[])
        KapLimitRel(ctx=[], fetch=[500])
          KapSortRel(sort0=[$12], dir0=[ASC], ctx=[])
            KapJoinRel(condition=[=($0, $11)], joinType=[left], ctx=[])
              KapTableScan(table=[[SSB, CUSTOMER]], ctx=[1@NDataflow [test]], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8]])
              KapTableScan(table=[[SSB, LINEORDER]], ctx=[2@NDataflow [test1]], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]])

      Q2:

      select CUSTOMER.C_PHONE
      ,LO_PARTKEY
      from SSB.CUSTOMER left join SSB.LINEORDER on CUSTOMER.C_CUSTKEY=LINEORDER.LO_CUSTKEY
      order by LINEORDER.LO_PARTKEY NULLS LAST
      LIMIT 500

      Calcite Plan

      KapLimitRel(ctx=[], fetch=[500])
        KapSortRel(sort0=[$1], dir0=[ASC], ctx=[])
          KapProjectRel(C_PHONE=[$6], LO_PARTKEY=[$12], ctx=[])
            KapJoinRel(condition=[=($0, $11)], joinType=[left], ctx=[])
              KapTableScan(table=[[SSB, CUSTOMER]], ctx=[1@NDataflow [test]], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8]])
              KapTableScan(table=[[SSB, LINEORDER]], ctx=[2@NDataflow [test1]], fields=[[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17]])
      

      In SortRel, the columns used are not pushed down to the sub OlapContext. To fix this issue, need to add the columns to the sub OlapContext.

      Attachments

        Activity

          People

            Jueyi Zhimin Wu
            Jueyi Zhimin Wu
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: