Files
Sampras Lopes 9df4e0193f feat(analytics): Add Clickhouse based analytics (#2988)
Co-authored-by: harsh_sharma_juspay <harsh.sharma@juspay.in>
Co-authored-by: Ivor Dsouza <ivor.dsouza@juspay.in>
Co-authored-by: Chethan Rao <70657455+Chethan-rao@users.noreply.github.com>
Co-authored-by: nain-F49FF806 <126972030+nain-F49FF806@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
Co-authored-by: akshay.s <akshay.s@juspay.in>
Co-authored-by: Gnanasundari24 <118818938+Gnanasundari24@users.noreply.github.com>
2023-11-29 11:34:53 +00:00

117 lines
3.8 KiB
SQL

CREATE TABLE payment_intents_queue (
`payment_id` String,
`merchant_id` String,
`status` LowCardinality(String),
`amount` UInt32,
`currency` LowCardinality(Nullable(String)),
`amount_captured` Nullable(UInt32),
`customer_id` Nullable(String),
`description` Nullable(String),
`return_url` Nullable(String),
`connector_id` LowCardinality(Nullable(String)),
`statement_descriptor_name` Nullable(String),
`statement_descriptor_suffix` Nullable(String),
`setup_future_usage` LowCardinality(Nullable(String)),
`off_session` Nullable(Bool),
`client_secret` Nullable(String),
`active_attempt_id` String,
`business_country` String,
`business_label` String,
`modified_at` DateTime CODEC(T64, LZ4),
`created_at` DateTime CODEC(T64, LZ4),
`last_synced` Nullable(DateTime) CODEC(T64, LZ4),
`sign_flag` Int8
) ENGINE = Kafka SETTINGS kafka_broker_list = 'kafka0:29092',
kafka_topic_list = 'hyperswitch-payment-intent-events',
kafka_group_name = 'hyper-c1',
kafka_format = 'JSONEachRow',
kafka_handle_error_mode = 'stream';
CREATE TABLE payment_intents_dist (
`payment_id` String,
`merchant_id` String,
`status` LowCardinality(String),
`amount` UInt32,
`currency` LowCardinality(Nullable(String)),
`amount_captured` Nullable(UInt32),
`customer_id` Nullable(String),
`description` Nullable(String),
`return_url` Nullable(String),
`connector_id` LowCardinality(Nullable(String)),
`statement_descriptor_name` Nullable(String),
`statement_descriptor_suffix` Nullable(String),
`setup_future_usage` LowCardinality(Nullable(String)),
`off_session` Nullable(Bool),
`client_secret` Nullable(String),
`active_attempt_id` String,
`business_country` LowCardinality(String),
`business_label` String,
`modified_at` DateTime DEFAULT now() CODEC(T64, LZ4),
`created_at` DateTime DEFAULT now() CODEC(T64, LZ4),
`last_synced` Nullable(DateTime) CODEC(T64, LZ4),
`inserted_at` DateTime DEFAULT now() CODEC(T64, LZ4),
`sign_flag` Int8,
INDEX connectorIndex connector_id TYPE bloom_filter GRANULARITY 1,
INDEX currencyIndex currency TYPE bloom_filter GRANULARITY 1,
INDEX statusIndex status TYPE bloom_filter GRANULARITY 1
) ENGINE = CollapsingMergeTree(
sign_flag
)
PARTITION BY toStartOfDay(created_at)
ORDER BY
(created_at, merchant_id, payment_id)
TTL created_at + toIntervalMonth(6)
;
CREATE MATERIALIZED VIEW kafka_parse_payment_intent TO payment_intents_dist (
`payment_id` String,
`merchant_id` String,
`status` LowCardinality(String),
`amount` UInt32,
`currency` LowCardinality(Nullable(String)),
`amount_captured` Nullable(UInt32),
`customer_id` Nullable(String),
`description` Nullable(String),
`return_url` Nullable(String),
`connector_id` LowCardinality(Nullable(String)),
`statement_descriptor_name` Nullable(String),
`statement_descriptor_suffix` Nullable(String),
`setup_future_usage` LowCardinality(Nullable(String)),
`off_session` Nullable(Bool),
`client_secret` Nullable(String),
`active_attempt_id` String,
`business_country` LowCardinality(String),
`business_label` String,
`modified_at` DateTime64(3),
`created_at` DateTime64(3),
`last_synced` Nullable(DateTime64(3)),
`inserted_at` DateTime64(3),
`sign_flag` Int8
) AS
SELECT
payment_id,
merchant_id,
status,
amount,
currency,
amount_captured,
customer_id,
description,
return_url,
connector_id,
statement_descriptor_name,
statement_descriptor_suffix,
setup_future_usage,
off_session,
client_secret,
active_attempt_id,
business_country,
business_label,
modified_at,
created_at,
last_synced,
now() as inserted_at,
sign_flag
FROM payment_intents_queue;