Skip to content

Instantly share code, notes, and snippets.

@den-crane
den-crane / AggregatingMergeTree-groupArrayState
Last active July 25, 2023 16:15
AggregatingMergeTree-groupArrayState
----------------------- SimpleAggregateFunction + groupArrayArray ----------------------------
drop table if exists states_raw;
drop table if exists final_states_by_month;
drop table if exists final_states_by_month_mv;
CREATE TABLE states_raw(d date, uid UInt64, s String) ENGINE = Null;
CREATE TABLE final_states_by_month(d date, uid UInt64, a_state SimpleAggregateFunction(groupArrayArray, Array(String)))
ENGINE = AggregatingMergeTree PARTITION BY toYYYYMM(d) ORDER BY (uid);