47 lines
925 B
SQL
47 lines
925 B
SQL
CREATE DATABASE IF NOT EXISTS telecom;
|
|
|
|
CREATE TABLE IF NOT EXISTS telecom.cdr_records
|
|
(
|
|
-- 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 now64(3)
|
|
)
|
|
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;
|