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.

  1. with_bounds(
  2. summary CounterSummary,
  3. bounds TSTZRANGE,
  4. ) RETURNS CounterSummary

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

Required arguments

NameTypeDescription
summaryCounterSummaryThe input CounterSummary
boundsTSTZRANGEA range of timestamptz representing the largest and smallest allowed times in this CounterSummary

Returns

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

Sample usage

  1. SELECT
  2. id,
  3. bucket,
  4. extrapolated_rate(
  5. with_bounds(
  6. summary,
  7. time_bucket_range('15 min'::interval, bucket)
  8. )
  9. )
  10. FROM (
  11. SELECT
  12. id,
  13. time_bucket('15 min'::interval, ts) AS bucket,
  14. counter_agg(ts, val) AS summary
  15. FROM foo
  16. GROUP BY id, time_bucket('15 min'::interval, ts)
  17. ) t