You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Abhishek Gayakwad <a....@gmail.com> on 2014/07/24 17:10:55 UTC
HIVE 0.12 SUM() returning NULL for decimal values
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 '000000_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 '000000_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
Posted by 丁桂涛(桂花) <di...@baixing.com>.
try
select sum(sales) from salestemp where sales is not null;
On Thu, Jul 24, 2014 at 11:10 PM, Abhishek Gayakwad <a....@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 '000000_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 '000000_0' looks like
> --------------------------------
> 24687329978.000156909543021743116491818900326715
> 246873303113.06617408356827568833561026591436615
> 246873314156.00031381908604348623298363780065343
> 2468733246.8943049855440756796081014881223248771
> 2468733280
> --------------------------------
>
> Please let me know what is going wrong here.
>
> Thanks
> Abhishek
>
--
丁桂涛