如何在stream
选择中每N分钟对来自pipelinedb的continuous view
的数据进行分组?
Pipelinedb的流获取有关来自许多远程主机的事件的数据。我需要在5分钟内按类型,IP和时间间隔对此事件进行分组,并计算它们。
所以输入我(非常粗略):
time | ip | type
------------------------------------
22:35 | 111.111.111.111 | page_open <-- new interaval, ends in 22:40
22:36 | 111.111.111.111 | page_open
22:37 | 111.111.111.111 | page_close
22:42 | 111.111.111.111 | page_close <-- event comes in next interval, ends in 22:45
22:42 | 222.111.111.111 | page_open
22:43 | 222.111.111.111 | page_open
22:44 | 222.111.111.111 | page_close
22:44 | 111.111.111.111 | page_open
在连续视图中必须选择的内容:
time | ip | type | count
---------------------------------------------
22:40 | 111.111.111.111 | page_open | 2
22:40 | 111.111.111.111 | page_close | 1
22:45 | 111.111.111.111 | page_open | 1
22:45 | 111.111.111.111 | page_close | 1
22:45 | 222.111.111.111 | page_open | 2
22:45 | 222.111.111.111 | page_close | 1
P.S。 对不起我的英文
答案 0 :(得分:0)
您可以使用date_round(column, interval)
[0]功能。例如,
CREATE CONTINUOUS VIEW bucketed AS
SELECT date_round(time, '5 minutes') AS bucket, COUNT(*)
FROM input_stream GROUP BY bucket;
[0] http://docs.pipelinedb.com/builtin.html?highlight=date_round