Skip to content

tdigest()

Aggregate data in a `tdigest` for further calculation of percentile estimates

Since 1.0.0

This is the first step for calculating approximate percentiles with the tdigest algorithm. Use tdigest to create an intermediate aggregate from your raw data. This intermediate form can then be used by one or more accessors in this group to compute final results.

Optionally, multiple such intermediate aggregate objects can be combined using rollup() before an accessor is applied.

Given a table called samples, with a column called data, build a tdigest using the data column. Use 100 buckets for the approximation.

SELECT tdigest(100, data) FROM samples;

The syntax is:

tdigest(
buckets INTEGER,
value DOUBLE PRECISION
) RETURNS TDigest
NameTypeDefaultRequiredDescription
bucketsINTEGER-Number of buckets in the digest. Increasing this provides more accurate quantile estimates, but requires more memory
valueDOUBLE PRECISION-Column of values to aggregate for the tdigest object
ColumnTypeDescription
tdigestTDigestA percentile estimator object created to calculate percentiles using the tdigest algorithm