Aggregate Functions

HoraeDB SQL is implemented with DataFusion, Here is the list of aggregate functions. See more detail, Refer to Datafusion

General

FunctionDescription
minReturns the minimum value in a numerical column
maxReturns the maximum value in a numerical column
countReturns the number of rows
avgReturns the average of a numerical column
sumSums a numerical column
array_aggPuts values into an array

Statistical

FunctionDescription
var / var_sampReturns the variance of a given column
var_popReturns the population variance of a given column
stddev / stddev_sampReturns the standard deviation of a given column
stddev_popReturns the population standard deviation of a given column
covar / covar_sampReturns the covariance of a given column
covar_popReturns the population covariance of a given column
corrReturns the correlation coefficient of a given column

Approximate

FunctionDescription
approx_distinctReturns the approximate number (HyperLogLog) of distinct input values
approx_medianReturns the approximate median of input values. It is an alias of approx_percentile_cont(x, 0.5).
approx_percentile_contReturns the approximate percentile (TDigest) of input values, where p is a float64 between 0 and 1 (inclusive). It supports raw data as input and build Tdigest sketches during query time, and is approximately equal to approx_percentile_cont_with_weight(x, 1, p).
approx_percentile_cont_with_weightReturns the approximate percentile (TDigest) of input values with weight, where w is weight column expression and p is a float64 between 0 and 1 (inclusive). It supports raw data as input or pre-aggregated TDigest sketches, then builds or merges Tdigest sketches during query time. TDigest sketches are a list of centroid (x, w), where x stands for mean and w stands for weight.