Aggregate functions
Functions that fold the rows of a group into one value. Names are case-insensitive. Parameters of a function go in a first pair of parentheses, as in quantile(0.9)(x). The combinators extend every function here.
| Name | Arguments | Description |
|---|---|---|
any | x | Returns the first value met in a group. |
anyLast | x | Returns the last value met in a group. |
argMax | arg, val | Returns arg from the row where val is largest. |
argMin | arg, val | Returns arg from the row where val is smallest. |
avg | x | Returns the arithmetic mean of a numeric column. |
avgWeighted | x, weight | Returns the mean of a column weighted by a second column. |
corr | x, y | Returns the Pearson correlation coefficient of two columns. |
count | [x] | Counts rows, or the rows where the argument is not NULL. |
covarPop | x, y | Returns the population covariance of two columns. |
covarSamp | x, y | Returns the sample covariance of two columns. |
deltaSum | x | Sums the increases between consecutive rows and ignores decreases. |
entropy | x | Returns the Shannon entropy of the values of a group. |
groupArray | x | Collects the values of a group into an array. |
groupBitAnd | x | Returns the bitwise AND of all values of a group. |
groupBitmap | x | Counts the distinct integers of a group with a bitmap. |
groupBitOr | x | Returns the bitwise OR of all values of a group. |
groupBitXor | x | Returns the bitwise XOR of all values of a group. |
kolmogorovSmirnovTest | value, sample_index | Returns the statistic and the p-value of the Kolmogorov-Smirnov test over two samples. |
kurtPop | x | Returns the population kurtosis. |
kurtSamp | x | Returns the sample kurtosis. |
mannWhitneyUTest | value, sample_index | Returns the U statistic and the p-value of the Mann-Whitney test over two samples. |
max | x | Returns the largest value of a column. |
maxMap | keys, values | Takes the largest value for each key over the rows of a group. |
median | x | Estimates the median of a group with a t-digest sketch. |
medianExact | x | Returns the exact median, taking the nearest rank. |
medianExactInterpolated | x | Returns the exact median, interpolating linearly between the two nearest values. |
min | x | Returns the smallest value of a column. |
minMap | keys, values | Takes the smallest value for each key over the rows of a group. |
quantile | (level)(x) | Estimates the quantile at the given level, between 0 and 1, of a group with a t-digest sketch. Without the parameter the level is 0.5. |
quantileExact | (level)(x) | Returns an exact quantile, taking the nearest rank. |
quantileExactInterpolated | (level)(x) | Returns an exact quantile, interpolating linearly between the two nearest values. |
quantiles | (level, ...)(x) | Estimates several quantiles of a group at once with a t-digest sketch and returns them as an array. Without parameters the levels are 0.25, 0.5, 0.75, 0.9 and 0.99. |
quantilesExact | (level, ...)(x) | Returns several exact quantiles as an array, taking the nearest rank. |
quantilesExactInterpolated | (level, ...)(x) | Returns several exact quantiles as an array, interpolating linearly between the two nearest values. |
retention | cond1, cond2, ... | Returns an array that tells, for each later condition, whether it held in a row together with the first condition. |
sequenceCount | timestamp, cond1, cond2, ... | Counts the event chains of a group that match a pattern of conditions. |
sequenceMatch | timestamp, cond1, cond2, ... | Returns 1 when the events of a group match a pattern of conditions. |
simpleLinearRegression | x, y | Fits a least-squares line and returns the slope and the intercept as an array. |
skewPop | x | Returns the population skewness. |
skewSamp | x | Returns the sample skewness. |
stddevPop | x | Returns the population standard deviation. |
stddevSamp | x | Returns the sample standard deviation. |
stochasticLinearRegression | target, feature1, ... | Trains a linear regression model with stochastic gradient descent and returns the weights as an array. |
stochasticLogisticRegression | target, feature1, ... | Trains a logistic regression model with stochastic gradient descent and returns the weights as an array. |
studentTTest | value, sample_index | Returns the t statistic and the p-value of Student's t-test over two samples. |
sum | x | Returns the sum of a numeric column. |
sumMap | keys, values | Sums the values for each key over the rows of a group. |
topK | (k)(x) | Returns the k most frequent values of a group, counted approximately. Without the parameter k is 10. |
uniq | x | Estimates the number of distinct values with a HyperLogLog sketch. |
uniqExact | x | Counts the exact number of distinct values. |
uniqUpTo | x | Counts distinct values up to a limit and returns the limit plus one above it. |
varPop | x | Returns the population variance. |
varSamp | x | Returns the sample variance. |
welchTTest | value, sample_index | Returns the t statistic and the p-value of Welch's t-test over two samples. |
windowFunnel | timestamp, cond1, cond2, ... | Returns the longest chain of conditions that hold in order within a time window. |