with_bounds()
A utility function to add bounds to an already-computed CounterSummary. The bounds represent the outer limits of the timestamps allowed for this CounterSummary as well as the edges of the range to extrapolate to in functions that allow it.
2. with_bounds(
4. summary CounterSummary,
6. bounds TSTZRANGE,
8. ) RETURNS CounterSummary
For more information about counter aggregation functions, see the hyperfunctions documentation.
Required arguments
| Name | Type | Description |
|---|---|---|
| summary | CounterSummary | The input CounterSummary |
| bounds | TSTZRANGE | A range of timestamptz representing the largest and smallest allowed times in this CounterSummary |
Returns
| Name | Type | Description |
|---|---|---|
| counter_agg | CounterSummary | A CounterSummary object that can be passed to accessor functions or other objects in the counter aggregate API |
Sample usage
2. SELECT
4. id,
6. bucket,
8. extrapolated_rate(
10. with_bounds(
12. summary,
14. time_bucket_range('15 min'::interval, bucket)
16. )
18. )
20. FROM (
22. SELECT
24. id,
26. time_bucket('15 min'::interval, ts) AS bucket,
28. counter_agg(ts, val) AS summary
30. FROM foo
32. GROUP BY id, time_bucket('15 min'::interval, ts)
34. ) t
