From 924d01208bd4ee8c374504d2dcc75b3a27730f03 Mon Sep 17 00:00:00 2001 From: Etienne Donneger Date: Mon, 19 Aug 2024 12:30:48 -0400 Subject: [PATCH] Fix missing quotes for cluster name in SQL schema --- create_schema.sh | 2 +- schema.sql | 43 +++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+), 1 deletion(-) diff --git a/create_schema.sh b/create_schema.sh index 569b725..b05e3c7 100755 --- a/create_schema.sh +++ b/create_schema.sh @@ -23,7 +23,7 @@ done ON_CLUSTER_DIRECTIVE="" ENGINE_TYPE="ReplacingMergeTree()" if [ -n "$CLUSTER_NAME" ]; then - ON_CLUSTER_DIRECTIVE="ON CLUSTER $CLUSTER_NAME" + ON_CLUSTER_DIRECTIVE="ON CLUSTER \"$CLUSTER_NAME\"" ENGINE_TYPE="ReplicatedReplacingMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}')" fi diff --git a/schema.sql b/schema.sql index 0d68df4..7354ab1 100644 --- a/schema.sql +++ b/schema.sql @@ -353,6 +353,49 @@ SELECT contract, timestamp AS updated_at_timestamp FROM supply_change_events; +-- Table to store token transfers primarily indexed by the 'contract' field -- +CREATE TABLE IF NOT EXISTS transfers_contract ON CLUSTER "antelope" +( + trx_id String, + action_index UInt32, + + contract String, + symcode String, + + from String, + to String, + quantity String, + memo String, + + precision UInt32, + amount Int64, + value Float64, + + block_num UInt64, + timestamp DateTime +) + ENGINE = ReplicatedReplacingMergeTree('/clickhouse/tables/{uuid}/{shard}', '{replica}') + PRIMARY KEY (contract, symcode, trx_id, action_index) + ORDER BY (contract, symcode, trx_id, action_index); + +CREATE MATERIALIZED VIEW transfers_contract_mv ON CLUSTER "antelope" + TO transfers_contract +AS +SELECT trx_id, + action_index, + contract, + symcode, + from, + to, + quantity, + memo, + precision, + amount, + value, + block_num, + timestamp +FROM transfer_events; + -- Table to store token transfers primarily indexed by the 'from' field -- CREATE TABLE IF NOT EXISTS transfers_from ON CLUSTER "antelope" (