-
Notifications
You must be signed in to change notification settings - Fork 27
null table schema update #277
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| CREATE MATERIALIZED VIEW IF NOT EXISTS insert_token_transfers_mv | ||
| TO token_transfers | ||
| AS SELECT | ||
| chain_id, | ||
| tt.1 AS token_type, | ||
| tt.2 AS token_address, | ||
| tt.3 AS token_id, | ||
| tt.4 AS from_address, | ||
| tt.5 AS to_address, | ||
| tt.6 AS block_number, | ||
| tt.7 AS block_timestamp, | ||
| tt.8 AS transaction_hash, | ||
| tt.9 AS transaction_index, | ||
| tt.10 AS amount, | ||
| tt.11 AS log_index, | ||
| tt.12 AS batch_index, | ||
| insert_timestamp, | ||
| is_deleted | ||
|
Comment on lines
+17
to
+18
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainSoft-delete semantics won’t propagate for existing rows. MVs are append-only. If 🏁 Script executed: #!/bin/bash
# Inspect token_transfers engine and primary key for upsert/dedup strategy
rg -nC3 -P 'CREATE\s+TABLE\s+(default\.)?token_transfers\b.*\n.*ENGINE\s*=\s*[A-Za-z]+' --type=sqlLength of output: 100 🏁 Script executed: #!/bin/bash
# Locate the CREATE TABLE definition for token_transfers
rg -nC3 'CREATE\s+TABLE.*token_transfers' -g '*.sql'
# Fallback: list all usages of token_transfers in SQL files for context
rg -nC3 'token_transfers' -g '*.sql'Length of output: 13207 🏁 Script executed: #!/bin/bash
# Extract the engine and ordering key for token_transfers
sed -n '1,50p' internal/tools/clickhouse/0006_clickhouse_create_token_transfers.sqlLength of output: 1560 🏁 Script executed: #!/bin/bash
sed -n '1,200p' internal/tools/clickhouse/0006_clickhouse_create_token_transfers.sqlLength of output: 3784 🏁 Script executed: #!/bin/bash
# Print the CREATE TABLE definition for insert_null_block_data
sed -n '1,200p' internal/tools/clickhouse/0004_clickhouse_create_insert_null_table.sqlLength of output: 3607 Soft-delete flags won’t propagate through this MV. Materialized views only append on inserts to insert_null_block_data; updates to is_deleted there won’t re-emit rows into token_transfers. To support soft-deletes, switch token_transfers to an engine that collapses on is_deleted (e.g. CollapsingMergeTree(is_deleted)) or use a proper version column with ReplacingMergeTree—and emit compensating delete rows via a dedicated MV/stream. 🤖 Prompt for AI Agents |
||
| FROM insert_null_block_data | ||
| ARRAY JOIN token_transfers AS tt | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tuple index misalignment: fields shifted by one → data corruption risk.
Per the new schema, the tuple layout starts with
chain_id, sotoken_typeshould bett.2,token_addresstt.3, …, andbatch_indextt.13. Current mapping is off-by-one. Fix as below; also castbatch_indexto nullable.🤖 Prompt for AI Agents