refactor Property components to be resused for both session/event data. Implement session-data screens + filtering. Remove all event-data specific compoenents/queries

This commit is contained in:
Francis Cao committed 2026-04-29 13:11:03 -07:00
1 parent 9da332c489
commit 680a1ca1a2
71 files changed
+2814 -958

No files matched your search

+36
View File
@@ -344,3 +344,39 @@ AS SELECT
groupArrayState(data_type) AS property_types
FROM umami.event_data
GROUP BY website_id, session_id, event_id, event_name, url_path, created_at;
-- Create session_data_pivot
CREATE TABLE IF NOT EXISTS umami.session_data_pivot
(
website_id UUID,
session_id UUID,
distinct_id String,
created_year_month UInt32,
created_at AggregateFunction(max, DateTime('UTC')),
property_keys AggregateFunction(groupArray, String),
property_values AggregateFunction(groupArray, String),
property_types AggregateFunction(groupArray, UInt32)
)
ENGINE = AggregatingMergeTree()
PARTITION BY created_year_month
ORDER BY (website_id, session_id, distinct_id)
SETTINGS index_granularity = 8192;
CREATE MATERIALIZED VIEW IF NOT EXISTS umami.session_data_pivot_mv
TO umami.session_data_pivot
AS SELECT
website_id,
session_id,
ifNull(distinct_id, '') AS distinct_id,
toYYYYMM(max(session_data.created_at)) AS created_year_month,
maxState(session_data.created_at) AS created_at,
groupArrayState(data_key) AS property_keys,
groupArrayState(multiIf(
data_type IN (1, 3, 5), ifNull(string_value, ''),
data_type = 2, toString(ifNull(number_value, 0)),
data_type = 4, toString(ifNull(date_value, toDateTime(0))),
''
)) AS property_values,
groupArrayState(data_type) AS property_types
FROM umami.session_data
GROUP BY website_id, session_id, distinct_id;