Impala Type Conversion Functions

Impala supports the following type conversion functions:

  • cast(expr as type)

Conversion functions are usually used in combination with other functions, to explicitly pass the expected data types. Impala has strict rules regarding data types for function parameters. For example, Impala does not automatically convert a DOUBLE value to FLOAT, a BIGINT value to INT, or other conversion where precision could be lost or overflow could occur. Use CAST when passing a column value or literal to a function that expects a parameter with a different type. For example:

select concat('Here are the first ',10,' results.'); -- Fails
select concat('Here are the first ',cast(10 as string),' results.'); -- Succeeds

The way this function deals with time zones when converting to or from TIMESTAMP values is affected by the --use_local_tz_for_unix_timestamp_conversions startup flag for the impalad daemon. See TIMESTAMP Data Type for details about how Impala handles time zone considerations for the TIMESTAMP data type.

Related information:

For details of casts from each kind of data type, see the description of the appropriate type: TINYINT Data Type, SMALLINT Data Type, INT Data Type, BIGINT Data Type, FLOAT Data Type, DOUBLE Data Type, DECIMAL Data Type (CDH 5.1 or higher only), STRING Data Type, CHAR Data Type (CDH 5.2 or higher only), VARCHAR Data Type (CDH 5.2 or higher only), TIMESTAMP Data Type, BOOLEAN Data Type