sync trace & short to clickhouse events
This commit is contained in:
@@ -10,8 +10,9 @@ DROP TABLE IF EXISTS shorturl_analytics.events;
|
||||
-- 创建新表
|
||||
CREATE TABLE IF NOT EXISTS shorturl_analytics.events (
|
||||
-- 事件基础信息
|
||||
event_id UUID DEFAULT generateUUIDv4(),
|
||||
event_time DateTime64(3) DEFAULT now64(),
|
||||
event_id String,
|
||||
event_time DateTime64(3),
|
||||
-- 精确到毫秒的时间戳
|
||||
event_type String,
|
||||
-- click, redirect, conversion, error
|
||||
event_attributes String DEFAULT '{}',
|
||||
@@ -25,7 +26,9 @@ CREATE TABLE IF NOT EXISTS shorturl_analytics.events (
|
||||
link_original_url String,
|
||||
link_attributes String DEFAULT '{}',
|
||||
link_created_at DateTime64(3),
|
||||
-- 精确到毫秒的时间戳
|
||||
link_expires_at Nullable(DateTime64(3)),
|
||||
-- 精确到毫秒的时间戳
|
||||
link_tags String DEFAULT '[]',
|
||||
-- Array of {id, name, attributes}
|
||||
-- 用户信息
|
||||
@@ -68,6 +71,6 @@ CREATE TABLE IF NOT EXISTS shorturl_analytics.events (
|
||||
conversion_type String,
|
||||
-- 改为String类型
|
||||
conversion_value Float64 DEFAULT 0
|
||||
) ENGINE = MergeTree() PARTITION BY toYYYYMM(event_time)
|
||||
) ENGINE = MergeTree() PARTITION BY toYYYYMM(event_time) -- 直接使用DateTime64进行分区
|
||||
ORDER BY
|
||||
(event_time, link_id, event_id) SETTINGS index_granularity = 8192;
|
||||
Reference in New Issue
Block a user