Reputation: 519
I want to display the decimal precision along with the result for decimal datatype in hive. However if there is no fraction part , in hive it will not display the decimal points.
hive> select cast(11 as decimal(14,2));
11
hive> select cast(11.22 as decimal(14,2));
11.22
In the above example instead of 11 it should display 11.00.How to achieve this? Please help.
Upvotes: 0
Views: 4705
Reputation: 11080
The following format_number()
function should do it.Source, return type will be string though.
select format_number(11,2)
Note: Precision and Scale were added from Hive 0.13.
Upvotes: 1
Reputation:
Use
round
orfloat_number
to set the decimal point where u like , example :
select round(SUM(150.100 + 127.0090), 2);
select float_number(var,2);
Upvotes: -1