rollup(CounterSummary)

  1. rollup(
  2. cs CounterSummary
  3. ) RETURNS CounterSummary

An aggregate to compute a combined CounterSummary from a series of non-overlapping CounterSummaries. Non-disjointed CounterSummaries cause errors.

For more information about counter aggregation functions, see the hyperfunctions documentation.

Required arguments

NameTypeDescription
csCounterSummaryThe input CounterSummary from a previous counter_agg (point form) call, often from a continuous aggregate

Returns

ColumnTypeDescription
counter_aggCounterSummaryA CounterSummary object that can be passed to accessor functions or other objects in the counter aggregate API

Sample usage

  1. WITH t as (
  2. SELECT
  3. date_trunc('day', ts) as dt,
  4. counter_agg(ts, val) AS counter_summary -- get a time weight summary
  5. FROM foo
  6. WHERE id = 'bar'
  7. GROUP BY date_trunc('day')
  8. ), q as (
  9. SELECT rollup(counter_summary) AS full_cs -- do a second level of aggregation to get the full CounterSummary
  10. FROM t
  11. )
  12. SELECT
  13. dt,
  14. delta(counter_summary), -- extract the delta from the CounterSummary
  15. delta(counter_summary) / (SELECT delta(full_cs) FROM q LIMIT 1) as normalized -- get the fraction of the delta that happened each day compared to the full change of the counter
  16. FROM t;