rollup( sketch uddsketch ) RETURNS UddSketch
rollup( digest tdigest ) RETURNS tdigest
This combines multiple outputs from the
percentile_agg() function (or either
tdigest()). This is especially
useful for re-aggregation in a continuous aggregate. For example, bucketing by a larger
time_bucket(), or re-grouping on other dimensions
included in an aggregation.
|The already constructed data structure from a previous |
|A UddSketch or tdigest object which may be passed to further APIs|
percentile_agg()](/hyperfunctions/percentile-approximation/aggregation-methods/percentile_agg/) function uses the UddSketch algorithm,
rollup returns the UddSketch data structure for use in further calls.
When using the
UddSketch aggregates, the
rollup function will not introduce additional error (compared to calculating the estimator directly), however, using
tdigest may introduce additional error compared to calculating the estimator directly on the underlying data.
Here, we re-aggregate an hourly continuous aggregate into daily buckets, the usage with
tdigest is analogous:
CREATE MATERIALIZED VIEW foo_hourly WITH (timescaledb.continuous) AS SELECT time_bucket('1 h'::interval, ts) as bucket, percentile_agg(value) as pct_agg FROM foo GROUP BY 1; SELECT time_bucket('1 day'::interval, bucket) as bucket, approx_percentile(0.95, rollup(pct_agg)) as p95, approx_percentile(0.99, rollup(pct_agg)) as p99 FROM foo_hourly GROUP BY 1;
Found an issue on this page?Report an issue!