PostgreSQL: 13.4
TimescaleDB: 2.4.2
When creating a view that is based on an existing view I cannot GROUP BY a time_bucket field. In the following example you can see three rows each at 20:00:00, those should be one row with the traffic tallied up. The 5min View does that as intended for the raw data.
As an example, here I tally the traffic in a 5min time_bucket (irrelevant data omitted from pictures):
With:
CREATE MATERIALIZED VIEW wifi_traffic_5m
WITH (timescaledb.continuous)
AS
SELECT
time_bucket('5 minutes', "timestamp") AS bucket_time,
clientid,
customer,
devicecpuid,
SUM(traffic) AS traffic
FROM ht_wifi_traffic_processed
GROUP BY bucket_time, clientid, customer, devicecpuid
Now I wanted to create a 15min view based on the 5min view, but I get this result:
With:
CREATE VIEW wifi_traffic_15m
AS
SELECT
time_bucket('15 minutes', bucket_time) AS bucket_time,
clientid,
customer,
devicecpuid,
SUM(traffic) AS traffic
FROM wifi_traffic_5m
GROUP BY bucket_time, clientid, customer, devicecpuid