Skip to content

Commit

Permalink
add tags to ch schema file
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscao633 committed Oct 17, 2024
1 parent 8759ba9 commit a708e6c
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions db/clickhouse/schema.sql
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ CREATE TABLE umami.website_event
--events
event_type UInt32,
event_name String,
tag String,
created_at DateTime('UTC'),
job_id Nullable(UUID)
)
Expand Down Expand Up @@ -96,6 +97,7 @@ CREATE TABLE umami.website_event_stats_hourly
views SimpleAggregateFunction(sum, UInt64),
min_time SimpleAggregateFunction(min, DateTime('UTC')),
max_time SimpleAggregateFunction(max, DateTime('UTC')),
tag SimpleAggregateFunction(groupArrayArray, Array(String)),
created_at Datetime('UTC')
)
ENGINE = AggregatingMergeTree
Expand Down Expand Up @@ -136,6 +138,7 @@ SELECT
views,
min_time,
max_time,
tag,
timestamp as created_at
FROM (SELECT
website_id,
Expand All @@ -161,6 +164,7 @@ FROM (SELECT
sumIf(1, event_type = 1) views,
min(created_at) min_time,
max(created_at) max_time,
arrayFilter(x -> x != '', groupArray(tag)) tag,
toStartOfHour(created_at) timestamp
FROM umami.website_event
GROUP BY website_id,
Expand Down

0 comments on commit a708e6c

Please sign in to comment.