Hive is automatically rounding of the precision

Viewed 338

I am doing a division operation in hive and it seems like automatically rounding of the values. Is there a way i can avoid this.

Example

 select cast(600/27701.47 as decimal(31,20));
+-------------------------+
|           _c0           |
+-------------------------+
| 0.02165950000000000000  |
+-------------------------+

Expected value:

0.0216595003803047

I am using hive on EMR - Hive 2.3.6-amzn-1

2 Answers

What version do you use?

In Hive 1.1.0-cdh5.14.2 it's working well.

enter image description here

It's bit late in responding, but I have a tricky answer for others.

select cast(600 as varchar(10))/cast(27701.47 as varchar(10));

It worked for me.

Related