combine only works on aggregate columns that belong to continuous views.
创建CONTINUOUS
1 2 3 | CREATE CONTINUOUS VIEW v AS SELECT g:: integer , AVG (x:: integer ) FROM stream GROUP BY g; CREATE CONTINUOUS VIEW |
插入数据
1 2 | INSERT INTO stream (g, x) VALUES (0, 10), (0, 10), (0, 10), (0, 10), (0, 10); INSERT INTO stream (g, x) VALUES (1, 20); |
查询结果
1 2 3 4 5 6 | pipeline=# SELECT * FROM v; g | avg ---+--------------------- 0 | 10.0000000000000000 1 | 20.0000000000000000 (2 rows ) |
1 2 3 4 5 | pipeline=# SELECT avg ( avg ) FROM v; avg --------------------- 15.0000000000000000 (1 row) |
使用Combine查询
1 2 3 4 5 | pipeline=# SELECT combine( avg ) FROM v; combine --------------------- 11.6666666666666667 (1 row) |
直接对表表v求平均值,只会对对CQL结果进行再次求平均值。
如果拿Combine,那么会对总的6条数据来进行求平均值。