Details
-
Sub-task
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 1.4
-
None
Description
Casting from an integer type to a legal Decimal type breaks down frequently.
I've used the following constraints to define what a legal decimal is:
smallint: 5 <= precision <= 38 && precision - scale >= 5
int: 10 <= precision <= 38 && precision - scale >= 10
bigint: 19 <= precision <= 38 && precision - scale >= 19
Example with smallint:
[localhost:21000] > select cast(-26659 as Decimal(27,18)); Query: select cast(-26659 as Decimal(27,18)) +--------------------------------+ | cast(-26659 as decimal(27,18)) | +--------------------------------+ | -3.454813489697914880 | +--------------------------------+ Returned 1 row(s) in 0.18s [localhost:21000] > select cast(-32130 as Decimal(36,29)); Query: select cast(-32130 as Decimal(36,29)) +----------------------------------+ | cast(-32130 as decimal(36,29)) | +----------------------------------+ | -0.00000000005300179331568369664 | +----------------------------------+