Updated on 2026-11-06 GMT+08:00

abs

The abs function is used to calculate the absolute value of the input parameter.

Syntax

abs(DOUBLE a)

Parameters

Parameter

Mandatory

Type

Description

a

Yes

DOUBLE, BIGINT, DECIMAL, or STRING

The format of parameter a includes floating-point format, integer format, and string format. If parameter a is not of type DOUBLE, it is implicitly converted to DOUBLE type before evaluation.

Return Values

Returns a value of type DOUBLE, INT, or DECIMAL.

If a is NULL, NULL is returned.

Example Code

Returns NULL.

select abs(null); 

Returns 1.

select abs(-1); 

Returns 3.1415926.

select abs(-3.1415926);