add tags to ch schema file

This commit is contained in:
Francis Cao 2024-10-17 09:53:07 -07:00
parent 8759ba9916
commit a708e6c350

View File

@ -26,6 +26,7 @@ CREATE TABLE umami.website_event
--events --events
event_type UInt32, event_type UInt32,
event_name String, event_name String,
tag String,
created_at DateTime('UTC'), created_at DateTime('UTC'),
job_id Nullable(UUID) job_id Nullable(UUID)
) )
@ -96,6 +97,7 @@ CREATE TABLE umami.website_event_stats_hourly
views SimpleAggregateFunction(sum, UInt64), views SimpleAggregateFunction(sum, UInt64),
min_time SimpleAggregateFunction(min, DateTime('UTC')), min_time SimpleAggregateFunction(min, DateTime('UTC')),
max_time SimpleAggregateFunction(max, DateTime('UTC')), max_time SimpleAggregateFunction(max, DateTime('UTC')),
tag SimpleAggregateFunction(groupArrayArray, Array(String)),
created_at Datetime('UTC') created_at Datetime('UTC')
) )
ENGINE = AggregatingMergeTree ENGINE = AggregatingMergeTree
@ -136,6 +138,7 @@ SELECT
views, views,
min_time, min_time,
max_time, max_time,
tag,
timestamp as created_at timestamp as created_at
FROM (SELECT FROM (SELECT
website_id, website_id,
@ -161,6 +164,7 @@ FROM (SELECT
sumIf(1, event_type = 1) views, sumIf(1, event_type = 1) views,
min(created_at) min_time, min(created_at) min_time,
max(created_at) max_time, max(created_at) max_time,
arrayFilter(x -> x != '', groupArray(tag)) tag,
toStartOfHour(created_at) timestamp toStartOfHour(created_at) timestamp
FROM umami.website_event FROM umami.website_event
GROUP BY website_id, GROUP BY website_id,