time_bucket 的 TimescaleDB GROUP BY 鉴于视图不起作用

TimescaleDB GROUP BY of time_bucket in view of view not working

PostgreSQL: 13.4
时标数据库:2.4.2

在创建基于现有视图的视图时,我无法按 time_bucket 字段进行分组。 在以下示例中,您可以在 20:00:00 处看到每行三行,这些应该是统计流量的一行。 5 分钟视图按照原始数据的预期执行此操作。

举个例子,我这​​里统计了5分钟的流量time_bucket(图片中省略了无关数据):

有:

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

现在我想在 5 分钟视图的基础上创建一个 15 分钟视图,但我得到了这个结果:

有:

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

好吧,在发布问题后不久我就自己找到了解决方案。 时间桶的名称在两个视图中不能相同。

如果我按如下方式编辑第二个视图:

CREATE VIEW wifi_traffic_15m
AS
    SELECT
        time_bucket('15 minutes', bucket_time) AS new_bucket_time,
        clientid,
        customer,
        devicecpuid,
        SUM(traffic) AS traffic
    FROM wifi_traffic_5m
    GROUP BY new_bucket_time, clientid, customer, devicecpuid

它按预期工作。