FAQ
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

Search Discussions

  • Paul Yang at Feb 25, 2011 at 2:49 am
    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
    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
  • Amareshwari Sri Ramadasu at Mar 15, 2011 at 11:00 am
    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" 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

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupuser @
categorieshive, hadoop
postedFeb 24, '11 at 7:32p
activeMar 15, '11 at 11:00a
posts3
users3
websitehive.apache.org

People

Translate

site design / logo © 2022 Grokbase