insert overwrite table test_data_type select name, decabs(cast(salary as double)) from test_data_type;
Hi here the data type of the salary is decimal(10,6) and i am trying to remove the trailing zeroes and insert the data into the same table, here the select is working but when i try to insert the data it is inserting with trailing zeros. eg:- 10.21010 expected output in the table - 10.2101
Any suggestion thanks.
CodePudding user response:
you can not do it. Hive automatically includes 0s in the end.
But if you need to display without a trailing 0, you can convert it to a string and the trim 0s from it.
select rtrim( cast(123.01000 as string),'0')
CodePudding user response:
It`s a feature. Hive will pad Decimal numbers with trailing zeros to the scale of the column.
If you want to use Decimal Type, you should accept this feature.
You can get some information from here: https://issues.apache.org/jira/browse/HIVE-12063