Uploaded image for project: 'Hive'
  1. Hive
  2. HIVE-16117

SortProjectTransposeRule should check for monotonicity preserving CAST

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.2.0
    • Fix Version/s: 2.2.0, 3.0.0
    • Component/s: CBO
    • Labels:
      None
    • Target Version/s:

      Description

      Due to CALCITE-1618, we need to move to new Calcite release to fix it.

      Due to this, SortProjectTransposeRule ignores CAST in the Project operator.

      For instance:

      ...
      HiveSortLimit(sort0=$4,sort1=$2,dir0=ASC-nulls-first,dir1=DESC-nulls-last,fetch=10)
        HiveProject(robot=$0,_o__c1=$2,m=$3,s=$4,(tok_function tok_int (tok_table_or_col robot))=CAST($0):INTEGER))
      ...
      

      will be transformed into:

      ...
      HiveProject(robot=$0,_o__c1=$2,m=$3,s=$4,(tok_function tok_int (tok_table_or_col robot))=CAST($0):INTEGER))
        HiveSortLimit(sort0=$0,sort1=$2,dir0=ASC-nulls-first,dir1=DESC-nulls-last,fetch=10)
      ...
      

      which is incorrect.

      The problem seems to be in the permutation method in RelOptUtil, which is called in L87. The method actually considers a CAST on a reference as a valid column permutation of the column referenced; probably it should not.

      permutation is only called by this rule and UnionPullUpConstantsRule, thus it seems it is safe to fix the semantics of the method.

        Attachments

        1. HIVE-16117.01.patch
          6 kB
          Jesus Camacho Rodriguez
        2. HIVE-16117.patch
          6 kB
          Jesus Camacho Rodriguez

          Issue Links

            Activity

              People

              • Assignee:
                jcamachorodriguez Jesus Camacho Rodriguez
                Reporter:
                jcamachorodriguez Jesus Camacho Rodriguez
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: