Skip to main content

int function

Applies to: check marked yes Databricks SQL check marked yes Databricks Runtime

Casts the value expr to INTEGER. This function is a synonym for CAST(expr AS INTEGER).

Syntax

int(expr)

Arguments

  • expr: Any expression which is castable to INTEGER.

Returns

An INTEGER.

If expr is a STRING that cannot be parsed as a number, Databricks raises a CAST_INVALID_INPUT error. If the value overflows the INTEGER range, Databricks raises a CAST_OVERFLOW error.

Common error conditions

Examples

SQL
> SELECT int(-5.6);
-5
> SELECT int('5');
5

> SELECT int('abc');
Error: CAST_INVALID_INPUT