0

I am using CDH 5.3.0 and Hive 0.12. I am having a Hive table with columns defined as double.

I am loading data to these double columns with 2 scale of precision after decimal point from a HDFS sequence file. For example, in my HDFS sequence file my data is like - 100.23 or 345.00. I need to choose double as my data value can be a big value like "3457894545.00"

My requirement is to display two scale precision after decimal point while querying to the Hive table. So with the example data, mentioned above, if i query for this column then I would need to see the value as "100.23" or "345.00".

But with Hive 0.12, I am getting only single precision after decimal point, i.e. value is getting truncated to "100.2" or "345.0".

I tried with "decimal" data type giving syntax as "decimal(3,2)" but in that case my value is getting completely rounded off i.e. "100" or "345".

I was goggling to see if there is any option to define custom precision to a double data type and found that custom precision can be given from hive 0.13 on wards.

Is Hive 0.12 double data type shows only single precision after decimal point. Do i need to apply any custom fix. Kindly suggests.

Thanks in advance.

Pralay Ghosh
  • 15
  • 1
  • 2
  • 10

1 Answers1

5

You should declare as decimal(5,2).

The syntax is DECIMAL(precision, scale). Precision means the number of digits of this number including the digits after the dot.

honk
  • 9,137
  • 11
  • 75
  • 83
Fiona Yang
  • 66
  • 1