Details
-
Bug
-
Status: Resolved
-
Blocker
-
Resolution: Fixed
-
Impala 2.3.0
Description
Impala returns wrong result for function 'conv'. Please see below command as example:
[10.17.80.14:21000] > select 2061013007, conv(2061013007, 16, 10), conv('2061013007', 16, 10) ; Query: select 2061013007, conv(2061013007, 16, 10), conv('2061013007', 16, 10) +------------+--------------------------+----------------------------+ | 2061013007 | conv(2061013007, 16, 10) | conv('2061013007', 16, 10) | +------------+--------------------------+----------------------------+ | 2061013007 | 1627467783 | 139066421255 | +------------+--------------------------+----------------------------+ Fetched 1 row(s) in 0.65s [10.17.80.14:21000] > select 2061013007, conv(cast(2061013007 as bigint), 16, 10), conv('2061013007', 16, 10) ; Query: select 2061013007, conv(cast(2061013007 as bigint), 16, 10), conv('2061013007', 16, 10) +------------+------------------------------------------+----------------------------+ | 2061013007 | conv(cast(2061013007 as bigint), 16, 10) | conv('2061013007', 16, 10) | +------------+------------------------------------------+----------------------------+ | 2061013007 | 1627467783 | 139066421255 | +------------+------------------------------------------+----------------------------+ Fetched 1 row(s) in 0.03s [10.17.80.14:21000] > select 2061013007, conv(cast(2061013007 as string), 16, 10), conv('2061013007', 16, 10) ; Query: select 2061013007, conv(cast(2061013007 as string), 16, 10), conv('2061013007', 16, 10) +------------+------------------------------------------+----------------------------+ | 2061013007 | conv(cast(2061013007 as string), 16, 10) | conv('2061013007', 16, 10) | +------------+------------------------------------------+----------------------------+ | 2061013007 | 139066421255 | 139066421255 | +------------+------------------------------------------+----------------------------+ Fetched 1 row(s) in 0.02s [10.17.80.14:21000] > select 2061013007, conv(cast(cast(2061013007 as decimal(20,0)) as bigint), 16, 10), conv('2061013007', 16, 10) ; Query: select 2061013007, conv(cast(cast(2061013007 as decimal(20,0)) as bigint), 16, 10), conv('2061013007', 16, 10) +------------+-----------------------------------------------------------------+----------------------------+ | 2061013007 | conv(cast(cast(2061013007 as decimal(20,0)) as bigint), 16, 10) | conv('2061013007', 16, 10) | +------------+-----------------------------------------------------------------+----------------------------+ | 2061013007 | 1627467783 | 139066421255 | +------------+-----------------------------------------------------------------+----------------------------+ Fetched 1 row(s) in 0.03s
Function conv(bigint, from_base, to_base) doesn't return correct result, while conv(string, from_base, to_base) returns correct value.
This happens in CDH5.5 as well.
Workaround
Cast value to string and use conv(string, from_base, to_base) for conversion.