Details
-
Bug
-
Status: Resolved
-
Critical
-
Resolution: Fixed
-
Impala 2.1, Impala 2.2
-
None
Description
When arguments to a function require casting because they don't match an exact function signature, the chosen signature should not result in loss of precision of the input arguments. (If loss of precision is unavoidable an error or warning should be given.)
Example of current behavior
Query: select greatest(0, cast('99999.8888' as decimal(30, 10))) +---------------------------------------------------+ | greatest(0, cast('99999.8888' as decimal(30,10))) | +---------------------------------------------------+ | 99999.890625 | +---------------------------------------------------+ Query: create table foo as select greatest(0, cast('99999.8888' as decimal(30, 10))) +-------------------+ | summary | +-------------------+ | Inserted 1 row(s) | +-------------------+ Fetched 1 row(s) in 3.72s Query: describe foo +------+-------+---------+ | name | type | comment | +------+-------+---------+ | _c0 | float | | +------+-------+---------+
Postgres and mysql both preserve the precision
mysql> select greatest(0, cast('99999.8888' as decimal(30, 10))); +----------------------------------------------------+ | greatest(0, cast('99999.8888' as decimal(30, 10))) | +----------------------------------------------------+ | 99999.8888000000 | +----------------------------------------------------+ mysql> create table foo as select greatest(0, cast('99999.8888' as decimal(30, 10))); Query OK, 1 row affected (0.02 sec) Records: 1 Duplicates: 0 Warnings: 0 mysql> desc foo; +----------------------------------------------------+----------------+------+-----+--------------+-------+ | Field | Type | Null | Key | Default | Extra | +----------------------------------------------------+----------------+------+-----+--------------+-------+ | greatest(0, cast('99999.8888' as decimal(30, 10))) | decimal(30,10) | NO | | 0.0000000000 | | +----------------------------------------------------+----------------+------+-----+--------------+-------+
Attachments
Issue Links
- is duplicated by
-
IMPALA-1879 mod() function doesn't always interpret fractional arguments as DECIMAL
- Resolved
- relates to
-
IMPALA-1713 ISNULL(A, B) - Impala should automaticaly cast second argument from type B to type A, if they are different and it possible.
- Resolved