Altering precision in HIVE

874 Views Asked by At

I want to set the precision of a column in my hive table to have a precision of 11 (11 places after the decimal). So say I have the double var:

var = 215.6666666666667

I want to get this down to two less precision:

var = 215.66666666667

Is there a way to do this in HIVE? I am using version 0.12.

1

There are 1 best solutions below

0
1218985 On

You can use the DECIMAL datatype in Hive which allows you to specify scale and precision of the decimal datatype when creating the table.The DECIMAL type in Hive is as same as Big Decimal format of Java. It is used for representing immutable arbitrary precision. The syntax and example is as follows:

DECIMAL(precision, scale)
decimal(10,0)

But Hive 0.12 does not support precision and scale for decimal. HIVE-3976 added support for decimal scale and precision, and is available in Hive 0.13.