0

I have created a simple table in impala like below

   CREATE TABLE IF NOT EXISTS my_db.employee
   (name STRING, salary double );

And my insert statement is like below

insert into employee (name, salary)
    VALUES ("Prasad", 158.17)

But the problem is

My values in impala is getting loaded as

name,salary
prasad,158.1666666666

I don't understand why this is happening. I have tried in other db's like hive but the value is getting loaded as 158.17 but in impala it is 158.1666666666

Can you please help me why this is happening ...

And how to load actual values...

Please guide me

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
prasad
  • 63
  • 2
  • 9

1 Answers1

0

This is a problem of floating point versus fixed point arithmetic. If you want the decimal portion to be exact, use decimal/numeric for the column:

CREATE TABLE IF NOT EXISTS my_db.employee 
    name STRING,
    salary DECIMAL(10, 2)
);
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786