mirror of
https://github.com/timescale/timescaledb.git
synced 2025-05-21 21:21:22 +08:00
The function `cagg_watermark` returns the time threshold at which materialized data ends and raw query data begins in a real-time aggregation query (union view). The watermark is simply the completed threshold of the continuous aggregate materializer. However, since the completed threshold will no longer exist with the new continuous aggregates, the watermark function has been changed to return the end of the last bucket in the materialized hypertable. In most cases, the completed threshold is the same as the end of the last materialized bucket. However, there are situations when it is not; for example, when there is a filter in the view query some buckets might not be materialized because no data matched the filter. The completed threshold would move ahead regardless. For instance, if there is only data from "device_2" in the raw hypertable and the aggregate has a filter `device=1`, there will be no buckets materialized although the completed threshold moves forward. Therefore the new watermark function might sometimes return a lower watermark than the old function. A similar situation explains the different output in one of the union view tests.