HIVE 0.12 SUM() returning NULL for decimal values

2014-07-24 Thread Abhishek Gayakwad
I am trying to aggregate one column of decimal type, which is returning me
null. If I cast this column to double it returns me some value. following
are the steps to recreate this scenario.


CREATE  TABLE salestemp(sku int, sales decimal);

LOAD DATA LOCAL INPATH '00_0' OVERWRITE INTO TABLE salestemp;

select sum(sales) from salestemp; // returns null

select sum(cast(sales AS double)) from salestemp; // returns
353.9609497977414


data in  '00_0'  looks like

24687329978.000156909543021743116491818900326715
246873303113.06617408356827568833561026591436615
246873314156.00031381908604348623298363780065343
2468733246.8943049855440756796081014881223248771
2468733280


Please let me know what is going wrong here.

Thanks
Abhishek


Re: HIVE 0.12 SUM() returning NULL for decimal values

2014-07-24 Thread 丁桂涛(桂花)
try
select sum(sales) from salestemp where sales is not null;


On Thu, Jul 24, 2014 at 11:10 PM, Abhishek Gayakwad a.gayak...@gmail.com
wrote:

 I am trying to aggregate one column of decimal type, which is returning me
 null. If I cast this column to double it returns me some value. following
 are the steps to recreate this scenario.

 
 CREATE  TABLE salestemp(sku int, sales decimal);

 LOAD DATA LOCAL INPATH '00_0' OVERWRITE INTO TABLE salestemp;

 select sum(sales) from salestemp; // returns null

 select sum(cast(sales AS double)) from salestemp; // returns
 353.9609497977414

 
 data in  '00_0'  looks like
 
 24687329978.000156909543021743116491818900326715
 246873303113.06617408356827568833561026591436615
 246873314156.00031381908604348623298363780065343
 2468733246.8943049855440756796081014881223248771
 2468733280
 

 Please let me know what is going wrong here.

 Thanks
 Abhishek




-- 
丁桂涛