abs function (Databricks SQL)

Returns the absolute value of the numeric value in expr.

Syntax

abs(expr)

Arguments

  • expr: An expression that evaluates to a numeric or interval.

Returns

A numeric or interval of the same type as expr.

For integral numeric types the function can return an ARITHMETIC_OVERFLOW error.

Examples

> SELECT abs(-1);
 1

> SELECT abs(cast(-32768 AS Smallint))
 Error: ARITHMETIC_OVERFLOW