Functions executing mathematical calculations.
Returns the absolute value of numeric_expression. Returns NULL if numeric_expression evaluates to NULL.
abs(expression)
The data type of the returned value is double, long, or duration.
data record(x = -42.13),record(x = 0),record(x = 6.8545)| fieldsAdd abs(x)
Query result:
Computes arc cosine of expression. The returned angle is in the range 0.0 through pi. Returns null if expression evaluates to NULL.
acos(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd acos(x)
Query result:
Computes arc sine of expression. The returned angle is in the range -pi/2 through pi/2. Returns null if <expression> evaluates to NULL.
asin(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd asin(x)
Query result:
Computes the arc tangent of expression. The returned angle is in the range -p/2 through pi/2. Returns null if expression evaluates to NULL.
atan(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd atan(x)
Query result:
Computes the angle theta from the conversion of rectangular coordinates (x, y) to polar coordinates (r, theta). Returns null if either of the expressions evaluates to NULL.
atan2(ordinate, abscissa)
The data type of the returned value is double.
data record(x = 1, y = 1),record(x = 2, y = 3),record(x = 4, y = 5)| fieldsAdd atan2(x, y)
Query result:
Rounds values down to a multiple of a given numeric bin size.
Used frequently in combination with summarize , by: ..... If it encounters a scattered set of values, they will be grouped into a smaller set of specific values.
bin(expression, interval)
The data type of the returned value is double, long, duration, or timestamp.
data record(x = -42.13),record(x = 0),record(x = 6.8545),record(x = 27)| fieldsAdd bin(x, 10), bin(x, 10, at:5)
Query result:
data record(timestamp = toTimestamp("2019-08-01T09:30:00.000-0400")),record(timestamp = toTimestamp("2022-12-24T18:13:23.672-0400")),record(timestamp = toTimestamp("2023-01-27T23:21:11.459-0400"))| fieldsAdd bin(timestamp, 1m), bin(timestamp, 1d)
Query result:
In this example, we align the timestamp to noon.
data record(timestamp = toTimestamp("2019-08-01T09:30:00.000-0400"))| fieldsAdd bin(timestamp, 1d, at: 12h)
Query result:
Calculates the smallest (closest to negative infinity) double value greater than or equal to the numeric_expression; is equal to a mathematical integer. Returns null if numeric_expression evaluates to NULL. The return type is of the same type as the input parameter.
ceil(expression)
The data type of the returned value is double or long.
data record(x = -0.5),record(x = 0),record(x = 0.5)| fieldsAdd ceil(x)
Query result:
Computes the trigonometric cosine of an angle expression (in radians). Returns null if expression evaluates to NULL.
cos(expression)
The data type of the returned value is double.
data record(x = -pi()),record(x = 0),record(x = pi())| fieldsAdd cos(x)
Query result:
Computes the hyperbolic cosine of an angle <expression>. Returns null if <expression> evaluates to NULL.
cosh(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd cosh(x)
Query result:
Calculates the real cubic root of a numeric expression.
cbrt (numeric_expression)
The data type of the returned value is double.
data record(x = -8),record(x = -42.13),record(x = 0),record(x = 6.8545)| fieldsAdd cbrt(x)
Query result:
Converts the numeric expression of an angle in degrees to an approximately equivalent angle as expressed in radians. Returns null if numeric_expr evaluates to NULL.
degreeToRadian(expression)
The data type of the returned value is double.
data record(degree = 90),record(degree = 180)| fieldsAdd degreeToRadian(degree)
Query result:
Returns Euler’s number.
e()
The data type of the returned value is double.
data record()| fieldsAdd e()
Query result:
Calculates the exponential function e^x, where e is the Euler's number and x is a numeric expression.
exp(expression)
The data type of the returned value is double.
data record(x = 1),record(x = 4)| fieldsAdd exp(x)
Query result:
Calculates the largest (closest to positive infinity) double value less than or equal to the numeric_expression; and is equal to a mathematical integer. Returns NULL if numeric_expression evaluates to NULL. The return type is of the same type as the input parameter.
floor(expression)
The data type of the returned value is double orlong.
data record(x = -0.5),record(x = 0),record(x = 0.5)| fieldsAdd floor(x)
Query result:
Returns sqrt(x^2 + y^2). Returns null if expression evaluates to NULL.
hypotenuse(x, y)
The data type of the returned value is double.
data record(x = 1, y = 2),record(x = 3, y = 4),record(x = 5, y = 6)| fieldsAdd hypotenuse(x, y)
Query result:
Calculates the natural logarithm (the base is e, the Euler's number) of a numeric expression.
log(expression)
The data type of the returned value is double.
data record(x = e()),record(x = 0),record(x = 1),record(x = 6.8545)| fieldsAdd log(x)
Query result:
Calculates log(1+x), where log is the natural logarithm and x is a numeric expression.
log1p(expression)
The data type of the returned value is double.
data record(x = 0),record(x = 6.8545)| fieldsAdd log1p(x)
Query result:
Calculates the decadic (common) logarithm (the base is 10) of a numeric expression.
log10(expression)
The data type of the returned value is double.
data record(x = 6.8545),record(x = 100)| fieldsAdd log10(x)
Query result:
Returns the constant value of PI (Archimedes’ number).
pi()
The data type of the returned value is double.
data record()| fieldsAdd pi()
Query result:
Raises a numeric expression to a given power.
power(base, exponent)
The data type of the returned value is double.
data record(base = 2, exponent = 4),record(base = 3, exponent = 5)| fieldsAdd power(base, exponent)
Query result:
Converts the numeric expression of an angle in radians to an approximately equivalent angle as expressed in degrees. Returns null if numeric_expr evaluates to NULL.
radianToDegree(numeric_expr)
The data type of the returned value is double.
data record(radian = pi() / 2),record(radian = pi())| fieldsAdd radianToDegree(radian)
Query result:
Creates a random double value. Generated values aren't deterministic. The value range of the generated double value is between 0.0 (inclusive) and 1.0 (exclusive).
random()
The data type of the returned value is double.
data record()| fieldsAdd random()
Query result:
Aligns the given value/timestamp to value range based on the provided alignment parameter. The range function is similar to the bin function, but produces a range instead, then provides information about the start and the end of the bin the value is aligned to.
range(expression, interval [, at])
The data type of the returned value is record.
data record(x = -42.13),record(x = 0),record(x = 6.8545),record(x = 27)| fieldsAdd range(x, 10),range(x, 10, at: 5)
Query result:
data record(timestamp = toTimestamp("2019-08-01T09:30:00.000-0400")),record(timestamp = toTimestamp("2022-12-24T18:13:23.672-0400")),record(timestamp = toTimestamp("2023-01-27T23:21:11.459-0400"))| fieldsAdd range(timestamp, 1m),range(timestamp, 1d)
Query result:
data record(timestamp = toTimestamp("2019-08-01T09:30:00.000-0400"))| fieldsAdd bin(timestamp, 1d, at: 12h)
Query result:
Rounds any numeric value to the specified number of decimal places. If you don't specify the number of decimal places, it rounds to the nearest integer. The return type is of the same type as the input parameter.
round(expression [, decimals])
The data type of the returned value is double or long.
data record(x = -0.5),record(x = 0),record(x = 0.5),record(x = 0.55)| fieldsAdd round(x),round(x, decimals: 1)
Query result:
Returns the signum (sign) result of an argument. It returns one of four possible values: -1 (if numeric_expression evaluates to a value less than 0), 0 (if numeric_expression evaluates to 0), 1 (if numeric_expression evaluates to a value greater than 0), or null (if numeric_expression evaluates to NULL).
The return type is of the same type as the input parameter.
signum(expression)
The data type of the returned value is double or long.
data record(x = -42.13),record(x = 0),record(x = 6.8545)| fieldsAdd signum(x)
Query result:
Computes the trigonometric sine of angle <expression> (in radians). Returns null if <expression> evaluates to NULL.
sin(expression)
The data type of the returned value is double.
data record(x = -pi() / 2),record(x = 0),record(x = pi() / 2)| fieldsAdd sin(x)
Query result:
Computes the hyperbolic sine of <expression>. Returns null if <expression> evaluates to NULL.
sinh(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd sinh(x)
Query result:
Computes the positive square root of a numeric expression.
sqrt(expression)
The data type of the returned value is double.
data record(x = 4),record(x = 81),record(x = -14)| fieldsAdd sqrt(x)
Query result:
Computes the trigonometric tangent of angle expression (in radians). Returns null if expression evaluates to NULL.
tan(expression)
The data type of the returned value is double.
data record(x = -pi() / 4),record(x = 0),record(x = pi() / 4)| fieldsAdd tan(x)
Query result:
Computes the hyperbolic tangent of expression. Returns null if expression evaluates to NULL.
tanh(expression)
The data type of the returned value is double.
data record(x = -1),record(x = 0),record(x = 1)| fieldsAdd tanh(x)
Query result: