Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
Impala 2.1
-
None
-
None
Description
It's unlikely that people would want their INT data to turn into a DOUBLE as part of ABS(). Other systems such as Postgresql retain the INT.
Query: create TABLE FOO AS SELECT ABS(CAST(1 AS INT)) col +-------------------+ | summary | +-------------------+ | Inserted 1 row(s) | +-------------------+ Fetched 1 row(s) in 0.33s [casey-desktop:21000] > desc foo; Query: describe foo +------+--------+---------+ | name | type | comment | +------+--------+---------+ | col | double | | +------+--------+---------+ Fetched 1 row(s) in 0.00s
functional=# CREATE TABLE FOO AS SELECT ABS(CAST(1 AS INT)) col; SELECT 1 functional=# \d foo; Table "public.foo" Column | Type | Modifiers --------+---------+----------- col | integer |
Example usage
Query: select now() + interval abs(int_col) year from alltypestiny ERROR: AnalysisException: Operand 'abs(int_col)' of timestamp arithmetic expression 'now() + INTERVAL abs(int_col) year' returns type 'DOUBLE'. Expected an integer type.