How to use uniqExactIf in materialized view

528 views
Skip to first unread message

michal...@glassboxdigital.com

unread,
Jan 4, 2021, 3:33:55 AM1/4/21
to ClickHouse
Hi,
I am using this setup:
1. target table
2. materialized view with engine type SummingMergeTree
And i am trying to define a uniqExactIf on the MV.

I tried using uniqExactIfState & uniqExactIfMerge but could not find how to define the AggregateFunction on the target table. AggregateFunction(uniqExactIf, UInt64) did not work.

So instead, i tried using:
uniqIf(session_uuid, struggle_severity='error') session_error_count_1,
uniqExactIf(session_uuid, struggle_severity='error') session_error_count_2,
count(distinct(session_uuid), struggle_severity='error') session_error_count_3
on the materialized view with:
session_error_count_1 Nullable(UInt64),
session_error_count_2 Nullable(UInt64),
session_error_count_3 Nullable(UInt64)
on the target table.
But when querying the MV with:
sum(session_error_count_1) as error_count_1,
sum(session_error_count_2) as error_count_2,
sum(session_error_count_3) as error_count_3

The numbers were a little different from what they should be.

Please advice.

thanks



michal...@glassboxdigital.com

unread,
Jan 4, 2021, 8:28:51 AM1/4/21
to ClickHouse
I found how to do this: define on target:
session_error_uniq AggregateFunction(uniqExactIf, UUID, UInt8),

Reply all
Reply to author
Forward
0 new messages