You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@hive.apache.org by Aurora Skarra-Gallagher <au...@yahoo-inc.com> on 2011/02/24 20:31:17 UTC

Specifying a double precision in HiveQL

Hi,

I have a Hive query that has a statement like this "(sum(itemcount) / count(item))". I want to specify only two digits of precision (i.e. 53.55). The result is stored inside of a string, not its own column, so I'd need to set the precision in the statement. Is this possible?

Thanks,
Aurora

RE: Specifying a double precision in HiveQL

Posted by Paul Yang <py...@fb.com>.
Hacky, but maybe something like

select concat( cast(num as int), '.' , cast(abs(num)*100 as int) % 100) from (select 1.234 as num from src limit 1) a;

?

-----Original Message-----
From: Aurora Skarra-Gallagher [mailto:aurora@yahoo-inc.com] 
Sent: Thursday, February 24, 2011 11:31 AM
To: user@hive.apache.org
Subject: Specifying a double precision in HiveQL

Hi,

I have a Hive query that has a statement like this "(sum(itemcount) / count(item))". I want to specify only two digits of precision (i.e. 53.55). The result is stored inside of a string, not its own column, so I'd need to set the precision in the statement. Is this possible?

Thanks,
Aurora

Re: Specifying a double precision in HiveQL

Posted by Amareshwari Sri Ramadasu <am...@yahoo-inc.com>.
You can use UDF round(x,d) which rounds of x to d decimal places

Thanks
Amareshwari

On 2/25/11 1:01 AM, "Aurora Skarra-Gallagher" <au...@yahoo-inc.com> wrote:

Hi,

I have a Hive query that has a statement like this "(sum(itemcount) / count(item))". I want to specify only two digits of precision (i.e. 53.55). The result is stored inside of a string, not its own column, so I'd need to set the precision in the statement. Is this possible?

Thanks,
Aurora