Skip to content

AggregateFunction

Oleg V. Kozlyuk edited this page Dec 24, 2021 · 2 revisions

AggregateFunction column type cannot be queried (or inserted to) directly. To insert into an AggregateFunction column, special functions with suffix ..State are required, like: uniqState, maxState, argMaxState.

Likewise, it's not possible to select directly from such column. To select, a function with ..Merge suffix is required: uniqMerge, maxMerge, argMaxState etc. This limitation stems from ClickHouse itself

Given a table with schema:

CREATE TABLE t (
    c AggregateFunction(uniq, Int8)
) ENGINE = Memory

The correct way to select from it would be:

SELECT uniqMerge(c) FROM t