Skip to content

Commit 101165b

Browse files
nischitprajakeloo
andauthored
null table schema update (#277)
* null table schema update * insert token transfers mv * minor change * nit schema update --------- Co-authored-by: Jake Loo <[email protected]>
1 parent bd2c31f commit 101165b

5 files changed

+43
-172
lines changed

internal/tools/clickhouse/0004_clickhouse_create_insert_null_table.sql

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
CREATE TABLE IF NOT EXISTS insert_null_block_data (
1+
CREATE TABLE IF NOT EXISTS insert_null_block_data
2+
(
23
chain_id UInt256,
3-
44
block Tuple(
55
block_number UInt256,
66
block_timestamp DateTime,
@@ -22,8 +22,7 @@ CREATE TABLE IF NOT EXISTS insert_null_block_data (
2222
gas_limit UInt256,
2323
gas_used UInt256,
2424
withdrawals_root FixedString(66),
25-
base_fee_per_gas Nullable(UInt64)
26-
),
25+
base_fee_per_gas Nullable(UInt64)),
2726
transactions Array(Tuple(
2827
hash FixedString(66),
2928
nonce UInt64,
@@ -55,8 +54,7 @@ CREATE TABLE IF NOT EXISTS insert_null_block_data (
5554
blob_gas_used Nullable(UInt64),
5655
blob_gas_price Nullable(UInt256),
5756
logs_bloom Nullable(String),
58-
status Nullable(UInt64)
59-
)),
57+
status Nullable(UInt64))),
6058
logs Array(Tuple(
6159
block_number UInt256,
6260
block_hash FixedString(66),
@@ -69,8 +67,7 @@ CREATE TABLE IF NOT EXISTS insert_null_block_data (
6967
topic_0 String,
7068
topic_1 String,
7169
topic_2 String,
72-
topic_3 String
73-
)),
70+
topic_3 String)),
7471
traces Array(Tuple(
7572
block_number UInt256,
7673
block_hash FixedString(66),
@@ -91,9 +88,21 @@ CREATE TABLE IF NOT EXISTS insert_null_block_data (
9188
value UInt256,
9289
author Nullable(FixedString(42)),
9390
reward_type LowCardinality(Nullable(String)),
94-
refund_address Nullable(FixedString(42))
95-
)),
96-
91+
refund_address Nullable(FixedString(42)))),
92+
token_transfers Array(Tuple(
93+
token_type LowCardinality(String),
94+
token_address FixedString(42),
95+
token_id UInt256,
96+
from_address FixedString(42),
97+
to_address FixedString(42),
98+
block_number UInt256,
99+
block_timestamp DateTime,
100+
transaction_hash FixedString(66),
101+
transaction_index UInt64,
102+
amount UInt256,
103+
log_index UInt64,
104+
batch_index Nullable(UInt16))),
97105
insert_timestamp DateTime DEFAULT now(),
98106
is_deleted UInt8 DEFAULT 0
99-
) ENGINE = Null;
107+
)
108+
ENGINE = Null

internal/tools/clickhouse/0007_clickhouse_create_token_transfers_mv.sql

Lines changed: 0 additions & 158 deletions
This file was deleted.

internal/tools/clickhouse/0011_clickhouse_create_address_transactions_mv.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE MATERIALIZED VIEW address_transactions_mv
1+
CREATE MATERIALIZED VIEW IF NOT EXISTS address_transactions_mv
22
TO address_transactions
33
AS
44
SELECT

internal/tools/clickhouse/0013_clickhouse_create_address_transfers_mv.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
CREATE MATERIALIZED VIEW address_transfers_mv
1+
CREATE MATERIALIZED VIEW IF NOT EXISTS address_transfers_mv
22
TO address_transfers
33
AS
44
SELECT
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
CREATE MATERIALIZED VIEW IF NOT EXISTS insert_token_transfers_mv
2+
TO token_transfers
3+
AS SELECT
4+
chain_id,
5+
tt.1 AS token_type,
6+
tt.2 AS token_address,
7+
tt.3 AS token_id,
8+
tt.4 AS from_address,
9+
tt.5 AS to_address,
10+
tt.6 AS block_number,
11+
tt.7 AS block_timestamp,
12+
tt.8 AS transaction_hash,
13+
tt.9 AS transaction_index,
14+
tt.10 AS amount,
15+
tt.11 AS log_index,
16+
tt.12 AS batch_index,
17+
insert_timestamp,
18+
is_deleted
19+
FROM insert_null_block_data
20+
ARRAY JOIN token_transfers AS tt

0 commit comments

Comments
 (0)