tdigest_quantile

tdigest_quantile(inputExpr: tdigest, quantile: const numeric) -> numeric or duration

Calculates a quantile from a TDigest state.

Domain

This is a scalar function (calculates a single output value for a single input row).

Categories

Examples

make_col quantile:tdigest_quantile(tdigest_col, .95)

Calculate the 95nd percentile of the data summarized in tdigest_col.

timechart 5m, durations_tdigest:tdigest(duration_col), group_by(^Cluster)
statsby quantile:tdigest_quantile(durations_tdigest, .98)

This is the typical use case: use t-digest to pre-aggregate numeric values with a decomposable aggregate function, and ultimately calculating a quantile value from it.

First, aggregate the durations both in time buckets of the desired width and by Cluster.

Then, calculate the 98th percentile.