Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 1.4
-
None
Description
I wrote a random decimal generator (for a given scale and precision), and ran a series of casts with the generated decimal expressed as a string, and conforming exactly to the scale and precision of the decimal it's being cast to. I occasionally run into something likes this:
Returned 1 row(s) in 0.17s [localhost:21000] > select cast("99.72202762551868586" as Decimal(19,17)); Query: select cast("99.72202762551868586" as Decimal(19,17)) +------------------------------------------------+ | cast('99.72202762551868586' as decimal(19,17)) | +------------------------------------------------+ | -84.74541311157683030 | +------------------------------------------------+
More details:
[localhost:21000] > select scale(cast("99.72202762551868586" as Decimal(19,17))); Query: select scale(cast("99.72202762551868586" as Decimal(19,17))) +-------------------------------------------------------+ | scale(cast('99.72202762551868586' as decimal(19,17))) | +-------------------------------------------------------+ | 17 | +-------------------------------------------------------+ Returned 1 row(s) in 0.18s [localhost:21000] > select precision(cast("99.72202762551868586" as Decimal(19,17))); Query: select precision(cast("99.72202762551868586" as Decimal(19,17))) +-----------------------------------------------------------+ | precision(cast('99.72202762551868586' as decimal(19,17))) | +-----------------------------------------------------------+ | 19 | +-----------------------------------------------------------+ Returned 1 row(s) in 0.18s ipython: In [1]: num = '99.72202762551868586' In [2]: print len(num) - 1 19
Nong, feel free to close this if it's a duplicate, but I haven't found any in-flight change (or jira) that this collides with.