[ 
https://issues.apache.org/jira/browse/HIVE-14252?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15450740#comment-15450740
 ] 

Varun Gullipalli commented on HIVE-14252:
-----------------------------------------

WITH AGGREGATE ON ROUNDED VALUES
select sum(row.r1),sum(row.r2) from (select round(amt, 2) as r1, round(txn_amt, 
2) as r2 from table1 limit 30) row;
8.309999999999999       6.379999999999999

WITH ROUNDING ONLY
select round(amt, 2), round(txn_amt, 2) from table1 limit 30;
0.31    0.24
0.12    0.09
0.15    0.12
0.45    0.35
0.12    0.09
0.25    0.19
0.24    0.19
0.12    0.09
0.26    0.2
0.04    0.03
0.43    0.33
0.16    0.12
0.69    0.53
0.05    0.04
0.04    0.03
0.6     0.46
0.14    0.1
0.09    0.07
0.05    0.04
0.12    0.09
0.05    0.04
0.18    0.13
0.03    0.02
0.04    0.03
0.02    0.01
0.14    0.11
0.02    0.02
0.02    0.02
0.07    0.05
0.04    0.03
----------------
5.04    3.86   -----> SUM
----------------

WITHOUT ROUNDING
select amt, txn_amt from table1 limit 30;
0.313862        0.23976
0.120382        0.09196
0.152637        0.1166
0.453304        0.34628
0.118287        0.09036
0.252703        0.19304
0.244586        0.18684
0.115146        0.08796
0.264798        0.20228
0.040476        0.03092
0.428432        0.32728
0.159968        0.1222
0.694225        0.53032
0.046341        0.0354
0.040267        0.03076
0.604894        0.46208
0.136405        0.1042
0.091373        0.0698
0.050425        0.03852
0.116036        0.08864
0.053619        0.04096
0.17641         0.13476
0.030475        0.02328
0.036235        0.02768
0.01639         0.01252
0.143369        0.10952
0.02016         0.0154
0.023092        0.01764
0.06849         0.05232
0.035397        0.02704

> Sum on Decimal rounding provides incorrect result
> -------------------------------------------------
>
>                 Key: HIVE-14252
>                 URL: https://issues.apache.org/jira/browse/HIVE-14252
>             Project: Hive
>          Issue Type: Bug
>            Reporter: Varun Gullipalli
>         Attachments: test data.txt
>
>
> hive> select sum(round(amt, 2)), sum(round(txn_amt, 2)) from table1  where DT 
> ='20160517'    
> union all
> select sum(round(amt,2)), sum(round(txn_amt,2)) from table2
> where DT ='20160517'   
> 99773.57999999997       77408.35
> 3336.1699999999996      2582.3500000000013



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to