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

SortProjectTransposeRule should check for monotonicity preserving CAST

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.2.0
    • 2.2.0, 3.0.0
    • CBO
    • None

    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
          jcamachorodriguez
        2. HIVE-16117.patch
          6 kB
          jcamachorodriguez

        Issue Links

          Activity

            People

              jcamacho Jesús Camacho Rodríguez
              jcamacho Jesús Camacho Rodríguez
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: