Skip to content

Commit 9015d3c

Browse files
authored
Merge pull request #9 from newgnart/feature/model-fct_transfer
Update environment variable references and add GraphQL data extractio…
2 parents 8cc5a50 + 4eb7658 commit 9015d3c

File tree

10 files changed

+328
-38
lines changed

10 files changed

+328
-38
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,6 @@ SNOWFLAKE_WAREHOUSE=
1515
SNOWFLAKE_DATABASE=
1616
SNOWFLAKE_SCHEMA=
1717
# Path to the private key file (.p8 or .pem) - used by dev/prod targets
18-
SNOWFLAKE_PRIVATE_KEY_FILE=/path/to/your/snowflake_key.p8
18+
SNOWFLAKE_PRIVATE_KEY_PATH=/path/to/your/snowflake_key.p8
1919
# Private key content (PEM format with newlines) - used by test target and CI
2020
# SNOWFLAKE_PRIVATE_KEY=

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ Required variables (see [.env.example](.env.example)):
158158
Optional (for Snowflake):
159159
- `SNOWFLAKE_ACCOUNT`, `SNOWFLAKE_USER`, `SNOWFLAKE_ROLE`, `SNOWFLAKE_WAREHOUSE`
160160
- `SNOWFLAKE_DATABASE`, `SNOWFLAKE_SCHEMA`
161-
- `SNOWFLAKE_PRIVATE_KEY_FILE`: Path to private key file (.p8 or .pem) for local development
161+
- `SNOWFLAKE_PRIVATE_KEY_PATH`: Path to private key file (.p8 or .pem) for local development
162162

163163
## Key Data Flows
164164

dbt_project/models/03_mart/fct_transfer.sql

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,22 @@ enriched as (
9393

9494
select
9595
transaction_hash,
96-
log_index,
96+
-- log_index,
9797
date_key,
98-
block_number,
99-
block_timestamp,
98+
-- block_number,
10099
contract_address,
101100
chain,
102101
from_address,
103102
to_address,
104-
symbol,
105-
name,
106-
decimals,
107103
transaction_type,
104+
-- symbol,
105+
-- name,
106+
-- decimals,
108107
amount,
109108

109+
-- Calculations last (ST06: simple targets before calculations)
110+
CONVERT_TIMEZONE('UTC', block_timestamp) as block_timestamp,
111+
110112
-- Audit column to track incremental runs
111113
CONVERT_TIMEZONE('UTC', CURRENT_TIMESTAMP()) as dbt_loaded_at
112114
from enriched

dbt_project/models/03_mart/models.yml

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -40,26 +40,18 @@ models:
4040
description: "Ethereum transaction hash"
4141
tests:
4242
- not_null
43-
- name: log_index
44-
description: "Log index within the transaction"
45-
tests:
46-
- not_null
4743
- name: date_key
4844
description: "Date dimension key in YYYYMMDD format"
4945
tests:
5046
- not_null
51-
- name: block_number
52-
description: "Block number where transfer occurred"
53-
tests:
54-
- not_null
55-
- name: block_timestamp
56-
description: "Block timestamp in UTC"
57-
tests:
58-
- not_null
5947
- name: contract_address
6048
description: "Token contract address"
6149
tests:
6250
- not_null
51+
- name: chain
52+
description: "Blockchain identifier (currently 'ethereum')"
53+
tests:
54+
- not_null
6355
- name: from_address
6456
description: "Sender address (0x0 for mints)"
6557
tests:
@@ -68,22 +60,22 @@ models:
6860
description: "Recipient address (0x0 for burns)"
6961
tests:
7062
- not_null
71-
- name: amount_raw
72-
description: "Transfer amount in smallest unit (before decimal adjustment)"
73-
- name: amount
74-
description: "Transfer amount adjusted for decimals (assuming 6 decimals)"
75-
- name: usd_value
76-
description: "Approximate USD value (for stablecoins)"
7763
- name: transaction_type
7864
description: "Type of transaction: transfer, mint, or burn"
7965
tests:
8066
- not_null
8167
- accepted_values:
8268
arguments:
8369
values: ["transfer", "mint", "burn"]
84-
# tests:
85-
# - dbt_utils.unique_combination_of_columns:
86-
# arguments:
87-
# combination_of_columns:
88-
# - transaction_hash
89-
# - log_index
70+
- name: amount
71+
description: "Transfer amount adjusted for token decimals"
72+
tests:
73+
- not_null
74+
- name: block_timestamp
75+
description: "Block timestamp in UTC"
76+
tests:
77+
- not_null
78+
- name: dbt_loaded_at
79+
description: "Timestamp when record was loaded by dbt"
80+
tests:
81+
- not_null

dbt_project/profiles.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ stables_analytics:
1313
type: snowflake
1414
account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}"
1515
user: "{{ env_var('SNOWFLAKE_USER') }}"
16-
private_key_file: "{{ env_var('SNOWFLAKE_PRIVATE_KEY_FILE') }}"
16+
private_key_path: "{{ env_var('SNOWFLAKE_PRIVATE_KEY_PATH') }}"
1717
role: "{{ env_var('SNOWFLAKE_ROLE') }}"
1818
database: "{{ env_var('SNOWFLAKE_DATABASE') }}"
1919
warehouse: "{{ env_var('SNOWFLAKE_WAREHOUSE') }}"
@@ -37,7 +37,7 @@ stables_analytics:
3737
type: snowflake
3838
account: "{{ env_var('SNOWFLAKE_ACCOUNT') }}"
3939
user: "{{ env_var('SNOWFLAKE_USER') }}"
40-
private_key_file: "{{ env_var('SNOWFLAKE_PRIVATE_KEY_FILE') }}"
40+
private_key_path: "{{ env_var('SNOWFLAKE_PRIVATE_KEY_PATH') }}"
4141
role: "{{ env_var('SNOWFLAKE_ROLE') }}"
4242
database: "{{ env_var('SNOWFLAKE_DATABASE') }}"
4343
warehouse: "{{ env_var('SNOWFLAKE_WAREHOUSE') }}"
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
-- Test that block numbers are within expected range
22

33
select block_number
4-
from {{ ref('fct_transfer') }}
4+
from {{ ref('stg_transfer') }}
55
where
66
block_number < 0
77
or block_number > 999999999 -- reasonable upper bound

0 commit comments

Comments
 (0)