Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 1.4
-
None
Description
Consider the following sequence:
[localhost:21000] > describe foo; Query: describe foo +------+----------------+---------+ | name | type | comment | +------+----------------+---------+ | d | decimal(38,38) | | +------+----------------+---------+ Returned 1 row(s) in 1.00s [localhost:21000] > insert into foo values(cast(0.1 as Decimal(38,38))); Query: insert into foo values(cast(0.1 as Decimal(38,38))) Inserted 1 rows in 0.38s [localhost:21000] > select * from foo; Query: select * from foo +------------------------------------------+ | d | +------------------------------------------+ | 0.09999999999999998358171037484709838848 | +------------------------------------------+ Returned 1 row(s) in 0.44s [localhost:21000] > insert into foo values(cast("0.1" as Decimal(38,38))); Query: insert into foo values(cast("0.1" as Decimal(38,38))) Inserted 1 rows in 0.38s [localhost:21000] > select * from foo; Query: select * from foo +------------------------------------------+ | d | +------------------------------------------+ | 0.09999999999999998358171037484709838848 | | 0.10000000000000000000000000000000000000 | +------------------------------------------+ Returned 2 row(s) in 0.44s
Nong told me that in the frontend, we first cast the the number in the query string to a double, and then recast it to decimal. Since the second cast is on Java's encoding of double, we get a very odd result when reading the column value as a Decimal. I'm not sure if it's possible to not do the cast when we're recasting it anyways, but that would be ideal.