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

Tez: Optimized Hashtable can support DECIMAL keys of same precision

    XMLWordPrintableJSON

Details

    Description

      Decimal support in the optimized hashtable was decided on the basis of the fact that Decimal(10,1) == Decimal(10, 2) when both contain "1.0" and "1.00".

      However, the joins now don't have any issues with decimal precision because they cast to common.

      create temporary table x (a decimal(10,2), b decimal(10,1)) stored as orc;
      insert into x values (1.0, 1.0);
      
          > explain logical select count(1) from x, x x1 where x.a = x1.b;
      OK  
      LOGICAL PLAN:
      $hdt$_0:$hdt$_0:x
        TableScan (TS_0)
          alias: x
          filterExpr: (a is not null and true) (type: boolean)
          Filter Operator (FIL_18)
            predicate: (a is not null and true) (type: boolean)
            Select Operator (SEL_2)
              expressions: a (type: decimal(10,2))
              outputColumnNames: _col0
              Reduce Output Operator (RS_6)
                key expressions: _col0 (type: decimal(11,2))
                sort order: +
                Map-reduce partition columns: _col0 (type: decimal(11,2))
                Join Operator (JOIN_8)
                  condition map:
                       Inner Join 0 to 1
                  keys:
                    0 _col0 (type: decimal(11,2))
                    1 _col0 (type: decimal(11,2))
                  Group By Operator (GBY_11)
                    aggregations: count(1)
                    mode: hash
                    outputColumnNames: _col0
      

      See cast up to Decimal(11, 2) in the plan, which normalizes both sides of the join to be able to compare HiveDecimal as-is.

      Attachments

        1. HIVE-14302.2.patch
          93 kB
          Mustafa İman
        2. HIVE-14302.3.patch
          105 kB
          Mustafa İman
        3. HIVE-14302.4.patch
          105 kB
          Mustafa İman
        4. HIVE-14302.5.patch
          128 kB
          Mustafa İman
        5. HIVE-14302.6.patch
          128 kB
          Mustafa İman
        6. HIVE-14302.patch
          30 kB
          Mustafa İman

        Issue Links

          Activity

            People

              mustafaiman Mustafa İman
              gopalv Gopal Vijayaraghavan
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 50m
                  50m