Open UnamedRus opened 4 years ago
It also would be useful if we have used a -Resample combinator as it produces constant sized bucketed arrays.
CREATE TABLE test_tbl_2_mv
(
`datetime` UInt32,
`state` SimpleAggregateFunction(maxForEach, Array(UInt8))
)
ENGINE = AggregatingMergeTree
PARTITION BY tuple()
ORDER BY intDiv(datetime, 300)
CREATE MATERIALIZED VIEW test_tbl_2_stream TO test_tbl_2_mv AS
SELECT
intDiv(datetime, 300),
maxResample(0, 10, 1)(value, intDiv(datetime, 30)) AS state
FROM test_tbl_2
GROUP BY intDiv(datetime, 300)
SELECT
intDiv(datetime, 300),
maxForEach(state)
FROM test_tbl_2_mv
GROUP BY intDiv(datetime, 300)
Use case Currently clickhouse supports a set of functions which can be used in SimpleAggregateFunction Data Type for AggregatingMergeTree, but it is not complete, for example it doesn't support -ForEach combinator which is stateless too.
Describe the solution you'd like Add -ForEach combinator as combinator which can be used in SimpleAggregateFunction.
Describe alternatives you've considered Use AggregateFunction instead, but it requires you to use -Merge, -State combinators and takes more space on disk.