fix(docker): provision durable topics and canonical ClickHouse schema
This commit is contained in:
41
app/worker/schema.sql
Normal file
41
app/worker/schema.sql
Normal file
@@ -0,0 +1,41 @@
|
||||
-- ClickHouse Initialization Script for Telecom CDR Ingestion Pipeline
|
||||
-- Database: telecom
|
||||
-- Table: {database}.{table}
|
||||
|
||||
CREATE DATABASE IF NOT EXISTS {database};
|
||||
|
||||
CREATE TABLE IF NOT EXISTS {database}.{table} (
|
||||
-- Identifiers
|
||||
cdr_id UUID,
|
||||
raw_id String,
|
||||
|
||||
-- Subscriber
|
||||
msisdn String,
|
||||
imsi String,
|
||||
|
||||
-- Session metadata
|
||||
service_type LowCardinality(String),
|
||||
radio_access_type LowCardinality(String),
|
||||
cell_id LowCardinality(String),
|
||||
|
||||
-- Traffic
|
||||
bytes_uploaded UInt64,
|
||||
bytes_downloaded UInt64,
|
||||
total_bytes UInt64,
|
||||
duration_seconds UInt32,
|
||||
|
||||
-- Timing
|
||||
session_start_time DateTime,
|
||||
session_end_time DateTime,
|
||||
|
||||
-- Network
|
||||
source_ip IPv4,
|
||||
|
||||
-- Audit
|
||||
processed_at DateTime64(3) DEFAULT now()
|
||||
|
||||
) ENGINE = ReplacingMergeTree(processed_at)
|
||||
PARTITION BY toYYYYMM(session_start_time)
|
||||
ORDER BY (service_type, radio_access_type, cell_id, session_start_time, msisdn, cdr_id)
|
||||
TTL session_start_time + INTERVAL 90 DAY
|
||||
SETTINGS index_granularity = 8192;
|
||||
Reference in New Issue
Block a user