Skip to main content
Version: 2.4.x

Math Functions

Math functions are a collection of functions used to perform various mathematical operations and calculations.They include basic arithmetic functions (such as addition, subtraction, multiplication, division), trigonometric functions (such as sin, cos, tan), exponential functions, logarithmic functions, etc.These functions can help you perform numerical calculations, solve mathematical problems, and create mathematical models.

abs

Returns the absolute value of a number.

abs(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View abs Example
SELECT abs(-10);
+-----------------+
| abs(Int64(-10)) |
+-----------------+
| 10.0 |
+-----------------+

acos

Return the inverse cosine of a number.

acos(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View acos Example
SELECT acos(0.5);
+--------------------+
| acos(Float64(0.5)) |
+--------------------+
| 1.0471975511965979 |
+--------------------+

acosh

Returns the hyperbolic cosine or hyperbolic cosecant of a number.

acosh(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View acosh Example
SELECT acosh(10);
+-------------------+
| acosh(Int64(10)) |
+-------------------+
| 2.993222846126381 |
+-------------------+

asin

Returns the arcsine of a number.

asin(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View asin Example
SELECT asin(1);
+--------------------+
| asin(Int64(1)) |
+--------------------+
| 1.5707963267948966 |
+--------------------+

asinh

Returns the area hyperbolic sine or inverse hyperbolic sine of a number.

asinh(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View asinh Example
SELECT asinh(1);
+-------------------+
| asinh(Int64(1)) |
+-------------------+
| 0.881373587019543 |
+-------------------+

atan

Returns the arctangent of a number.

atan(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View atan Example
SELECT atan(1);
+--------------------+
| atan(Int64(1)) |
+--------------------+
| 0.7853981633974483 |
+--------------------+

atanh

Returns the hyperbolic tangent or inverse hyperbolic tangent of a number.

atanh(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View atanh Example
SELECT atanh(0.3);
+---------------------+
| atanh(Float64(0.3)) |
+---------------------+
| 0.30951960420311175 |
+---------------------+

atan2

Return the arctangent of expression_y / expression_x

atan2(expression_y, expression_x)
ParametersDescription
expression_yThe first numerical expression to operate.Can be a constant, column, or function, and any combination of arithmetic operators.
expression_xThe second numerical expression to operate.Can be a constant, column, or function, and any combination of arithmetic operators.
View atan2 Example
SELECT atan2(10, 2);
+---------------------------+
| atan2(Int64(10),Int64(2)) |
+---------------------------+
| 1.3734008 |
+---------------------------+

cbrt

Return the cube root of a number.

cbrt(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View cbrt Example
SELECT cbrt(8);
+----------------+
| cbrt(Int64(8)) |
+----------------+
| 2.0 |
+----------------+

ceil

Round up.

ceil(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View ceil Example
SELECT ceil(1.6);
+--------------------+
| ceil(Float64(1.6)) |
+--------------------+
| 2.0 |
+--------------------+

cos

Returns the cosine of a number.

cos(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View cos Example
SELECT cos(1);
+--------------------+
| cos(Int64(1)) |
+--------------------+
| 0.5403023058681398 |
+--------------------+

cosh

Returns the hyperbolic cosine of a number.

cosh(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View cosh Example
SELECT cosh(2);
+--------------------+
| cosh(Int64(2)) |
+--------------------+
| 3.7621956910836314 |
+--------------------+

exp

Returns the exponential of a number with base e.

exp(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View exp Example
SELECT exp(1);
+-------------------+
| exp(Int64(1)) |
+-------------------+
| 2.718281828459045 |
+-------------------+

factorial

Factorial.If the value is less than 2, return 1.

factorial(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View factorial Example
SELECT factorial(5);
+---------------------+
| factorial(Int64(5)) |
+---------------------+
| 120 |
+---------------------+

floor

Floor.

floor(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View floor Example
SELECT floor(-3.1);
+----------------------+
| floor(Float64(-3.1)) |
+----------------------+
| -4.0 |
+----------------------+

gcd

Returns the greatest common divisor of expression_x and expression_y.If both inputs are zero, return 0.

gcd(expression_x, expression_y)
ParametersDescription
expression_xCan be a constant, column, or function, and any combination of arithmetic operators.
expression_yCan be a constant, column, or function, and any combination of arithmetic operators.
View gcd Example
SELECT gcd(24,36);
+--------------------------+
| gcd(Int64(24),Int64(36)) |
+--------------------------+
| 12 |
+--------------------------+

lcm

Returns the least common multiple of expression_x and expression_y.If any input value is zero, return 0.

lcm(expression_x, expression_y)
ParametersDescription
expression_xCan be a constant, column, or function, and any combination of arithmetic operators.
expression_yCan be a constant, column, or function, and any combination of arithmetic operators.
View lcm Example
SELECT lcm(4, 7);
+------------------------+
| lcm(Int64(4),Int64(7)) |
+------------------------+
| 28 |
+------------------------+

ln

Returns the natural logarithm of a number.

ln(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View ln Example
SELECT ln(5);
+--------------------+
| ln(Int64(5)) |
+--------------------+
| 1.6094379124341003 |
+--------------------+

log

Returns the base x logarithm of a number.Can provide a specified radix, or if omitted, defaults to a radix of 10.

log(base, numeric_expression)
log(numeric_expression)
ParametersDescription
baseCardinality: Can be a constant, column, or function, and any combination of arithmetic operators.
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View log Example
SELECT log(10, 2);
+-------------------------+
| log(Int64(10),Int64(2)) |
+-------------------------+
| 0.30102998 |
+-------------------------+

log10

Returns the base 10 logarithm of a number.

log10(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View log10 Example
SELECT log10(2);
+--------------------+
| log10(Int64(2)) |
+--------------------+
| 0.3010299956639812 |
+--------------------+

log2

Return the base 2 logarithm of a number.

log2(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View log2 Example
SELECT log2(2);
+----------------+
| log2(Int64(2)) |
+----------------+
| 1.0 |
+----------------+

pi

Return the approximate value of π.

pi()
View pi Example
SELECT pi();
+-------------------+
| pi() |
+-------------------+
| 3.141592653589793 |
+-------------------+

power

Returns the exponentiation of a base expression.

power(base, exponent)
ParametersDescription
baseExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
exponentThe numerical expression of the exponent to be calculated.Can be a constant, column, or function, and any combination of arithmetic operators.
View power Example
SELECT power(10, 2);
+---------------------------+
| power(Int64(10),Int64(2)) |
+---------------------------+
| 100 |
+---------------------------+

pow

Alias for power

radians

Converts degrees to radians.

radians(numeric_expression)
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
View radians Example
SELECT radians(10);
+---------------------+
| radians(Int64(10)) |
+---------------------+
| 0.17453292519943295 |
+---------------------+

random

Returns a random floating-point value within the range of 0 to -1.The random seed is unique for each row.

random()
View random Example
SELECT random();
+--------------------+
| random() |
+--------------------+
| 0.9232278829675913 |
+--------------------+

round

Round the number to the nearest integer.

round(numeric_expression[, decimal_places])
ParametersDescription
numeric_expressionExpression to operate on.Can be a constant, column, or function, and any combination of arithmetic operators.
decimal_placesDecimal places: Optional.Number of decimal places to round to.Default is 0.
View round Example
SELECT round(2.3);
+---------------------+
| round(Float64(2.3)) |
+---------------------+
| 2.0 |
+---------------------+

signum

Return the sign of a number.Negative numbers return -1.Zero and positive number return 1.

signum(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View signum Example
SELECT signum(10);
+-------------------+
| signum(Int64(10)) |
+-------------------+
| 1.0 |
+-------------------+

sin

Return the sine value of a number.

sin(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View sin Example
SELECT sin(5);

+---------------------+
| sin(Int64(5)) |
+---------------------+
| -0.9589242746631385 |
+---------------------+

sinh

Returns the hyperbolic sine of a number.

sinh(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View sinh Example
SELECT sinh(2);
+-------------------+
| sinh(Int64(2)) |
+-------------------+
| 3.626860407847019 |
+-------------------+

sqrt

Return the square root of a number.

sqrt(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View sqrt Example
SELECT sqrt(25);
+-----------------+
| sqrt(Int64(25)) |
+-----------------+
| 5.0 |
+-----------------+

tan

Returns the tangent value of a number.

tan(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View tan Example
SELECT tan(10);
+--------------------+
| tan(Int64(10)) |
+--------------------+
| 0.6483608274590866 |
+--------------------+

tanh

Return the hyperbolic tangent value of a number.

tanh(numeric_expression)
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
View tanh Example
SELECT tanh(10);
+--------------------+
| tanh(Int64(10)) |
+--------------------+
| 0.9999999958776927 |
+--------------------+

trunc

Truncate a number to an integer or truncate to the specified number of decimal places.

trunc(numeric_expression[, decimal_places])
ParametersDescription
numeric_expressionCan be a constant, column, or function, and any combination of arithmetic operators.
decimal_placesDecimal places: Optional.The number of decimal places to truncate to.Default is 0 (truncated to an integer).If decimal_places is a positive integer, truncate digits to the right of the decimal point.If decimal_places is a negative integer, replace digits to the left of the decimal point with 0.
View trunc Example
SELECT trunc(3.1415926, 2);