Denys Kuzmenko created HIVE-30154:
-------------------------------------

             Summary: CBO: HiveAggregateJoinTransposeRule changes the result 
type of a DECIMAL SUM
                 Key: HIVE-30154
                 URL: https://issues.apache.org/jira/browse/HIVE-30154
             Project: Hive
          Issue Type: Bug
            Reporter: Denys Kuzmenko


With hive.transpose.aggr.join=true, a SUM over a DECIMAL column that the rule 
pushes below a join returns a type 10 digits wider than the same query without 
the rule. The values are equal, but the type is visible to users: CTAS column 
types and result set metadata change.

Repro:
{code}
create table zz_fact (k int, v decimal(7,2));                                   
                                                                                
                                
  create table zz_dim (k int, name string);                                     
                                                                                
                                  
  insert into zz_fact values (1, 10.25), (1, 20.50), (2, 30.75), (2, 1.00), (3, 
5.55);                                                                          
                                  
  insert into zz_dim values (1, 'a'), (2, 'b'), (3, 'a');                       
                                                                                
                                  
  analyze table zz_fact compute statistics for columns;                         
                                                                                
                                  
  analyze table zz_dim compute statistics for columns;                          
                                                                                
                                  
                                                                                
                                                                                
                                  
  set hive.transpose.aggr.join=true;                                            
                                                                                
                                  
  create table zz_ctas_on as select name, sum(v) s from zz_fact join zz_dim on 
zz_fact.k = zz_dim.k group by name;                                             
                                   
  describe zz_ctas_on;   -- s decimal(27,2)                                     
                                                                                
                                  
                                                                                
                                                                                
                                  
  set hive.transpose.aggr.join=false;                                           
                                                                                
                                  
  create table zz_ctas_off as select name, sum(v) s from zz_fact join zz_dim on 
zz_fact.k = zz_dim.k group by name;                                             
                                  
  describe zz_ctas_off;  -- s decimal(17,2)         
{code}

  Both tables hold the same rows: a 36.30, b 31.75.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to