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

Add constraint checks to CBO plan

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 4.0.0-alpha-1
    • CBO
    • None

    Description

      create table acid_uami(i int,
                       de decimal(5,2) constraint nn1 not null enforced,
                       vc varchar(128) constraint nn2 not null enforced) clustered by (i) into 2 buckets stored as orc TBLPROPERTIES ('transactional'='true');
      explain
      update acid_uami set de=null where i=1;
      

      Non-CBO path:

      Map Operator Tree:
      TableScan
                  alias: acid_uami
                  filterExpr: ((i = 1) and enforce_constraint(vc is not null)) (type: boolean)
                  Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column stats: NONE
                  Filter Operator
                    predicate: ((i = 1) and enforce_constraint(vc is not null)) (type: boolean)
      

      CBO path:

          Map Reduce
            Map Operator Tree:
                TableScan
                  alias: acid_uami
                  filterExpr: (i = 1) (type: boolean)
                  Statistics: Num rows: 1 Data size: 216 Basic stats: COMPLETE Column stats: NONE
                  Filter Operator
                    predicate: (i = 1) (type: boolean)
      ...
            Reduce Operator Tree:
      ...
               Filter Operator
                  predicate: enforce_constraint((null is not null and _col3 is not null)) (type: boolean)
      

      In CBO path the enforce_constraint function is added to the plan when CBO plan is already generated and optimized.

      HiveSortExchange(distribution=[any], collation=[[0]])
        HiveProject(row__id=[$5], i=[CAST(1):INTEGER], _o__c2=[null:NULL], vc=[$2])
          HiveFilter(condition=[=($0, 1)])
            HiveTableScan(table=[[default, acid_uami]], table:alias=[acid_uami])
      

      Attachments

        1. HIVE-23089.6.patch
          44 kB
          Krisztian Kasa
        2. HIVE-23089.6.patch
          44 kB
          Krisztian Kasa
        3. HIVE-23089.5.patch
          44 kB
          Krisztian Kasa
        4. HIVE-23089.4.patch
          43 kB
          Krisztian Kasa
        5. HIVE-23089.3.patch
          32 kB
          Krisztian Kasa
        6. HIVE-23089.2.patch
          32 kB
          Krisztian Kasa
        7. HIVE-23089.1.patch
          16 kB
          Krisztian Kasa

        Issue Links

          Activity

            People

              kkasa Krisztian Kasa
              kkasa Krisztian Kasa
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: