# OPAL Numeric Functions¶

Numeric functions act on and/or produce numeric values, for your mathematical calculation needs.

Function

Description

abs

Returns the absolute value of ‘val’.

array_length

Returns the number of elements in an array, or null if input is not an array.

ceil

Returns ‘val’ rounded up to the given ‘precision’.

count

Count the number of non-null items in the group.

count_distinct

Estimate the approximate number of distinct values in the input using hyper-log-log.

count_distinct_exact

Count the exact number of distinct values in the input using complete enumeration (slower than count_distinct).

dense_rank

Returns the dense rank within an ordered group of values.

exp

Returns Euler’s number e raised to the given number.

float64

Generate a float representation of the argument value.

float64_null

Returns a null value of type float64.

floor

Returns ‘val’ rounded down to the given ‘precision’.

hash

Accepts a variable number of arguments of arbitrary types and returns a signed 64-bit hash.

haversine_distance_km

Computes the great circle approximate distance between two latitude/longitude coordinates, using the haversine formula.

int64

Generate a int representation of the argument value.

int64_null

Returns a null value of type int64.

int_div

Returns the integer quotient of the dividend divided by the divisor and truncates the remainder.

ipv4_network_int64

ipv4_to_int64

ln

Returns natural logarithm of a numeric expression.

log

Returns logarithm of a numeric expression (second argument) with the provided base (first argument).

mod

Returns the remainder when dividend is divided by the divisor.

numeric_null

Returns a null value of type numeric.

parse_hex

Parses a string encoded hex number and returns an int64.

percentile_disc

Assuming a discrete distribution, it returns the value for the specified percentile of the input expression across the group.

pow

Returns a number ‘base’ raised to the specified power ‘exponent’.

prom_quantile

prom_quantile calculates an approximate percentile value based on the distribution in a histogram metric that was generated by a Prometheus data source.

rank

Returns the rank within an ordered group of values.

round

Returns ‘val’ rounded to the given ‘precision’.

row_number

Return the window index of the row within its groupby, when ordered by the orderby.

sqrt

Returns the square root for a given input and null if input is negative.

strlen

Compute the length of an input string.

width_bucket

Construct equi-width histogram by dividing up the range between min and max with num_buckets buckets, and compute an integer ID for each value.