Create PoC of generalized ClickHouse events storage.
Summary
Provide a PoC of a single table for all usage events in ClickHouse and PG.
# PG
CREATE TABLE ai_usage_events (
id bigint NOT NULL,
"timestamp" timestamp with time zone NOT NULL,
user_id bigint NOT NULL,
created_at timestamp with time zone NOT NULL,
event smallint NOT NULL,
organization_id bigint NOT NULL,
namespace_path text,
extras jsonb,
CONSTRAINT check_628cdfbf3f CHECK ((char_length(namespace_path) <= 255))
)
PARTITION BY RANGE ("timestamp");
# CH
CREATE TABLE ai_usage_events
(
`user_id` UInt64 DEFAULT 0,
`event` UInt8 DEFAULT 0,
`namespace_path` String DEFAULT '0/',
`timestamp` DateTime64(6, 'UTC') DEFAULT now64(),
`extras` String
)
ENGINE = ReplacingMergeTree
PARTITION BY toYear(timestamp)
ORDER BY (namespace_path, user_id, event, timestamp)
SETTINGS index_granularity = 8192;
Verify that full E2E process works by migrated TroubleshootJobEvent class.
Edited by 🤖 GitLab Bot 🤖