Skip to content

Commit 09618a5

Browse files
committed
feature: rebuild fact tables.
1 parent 9b2ed30 commit 09618a5

33 files changed

+839
-321
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
with
2+
loans as (
3+
select * from {{ ref("int_goldsky_borrower_operations_mezo__loans_graph") }}
4+
),
5+
6+
first_touch_point as (
7+
select * from {{ ref("int_segment__sessions_first_touch_point") }}
8+
),
9+
10+
filtered_loan as (
11+
select
12+
l.*,
13+
coalesce(f.referrer_id, 'unknown') as referrer_id,
14+
coalesce(f.referrer_source, 'unknown') as referrer_source,
15+
coalesce(f.referrer_medium, 'unknown') as referrer_medium
16+
from loans as l
17+
left join
18+
first_touch_point as f on l.canonical_segment_id = f.canonical_segment_id
19+
)
20+
21+
select *
22+
from filtered_loan
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
version: 2
2+
models:
3+
- name: int_goldsky_borrower_operations_mezo__loans_graph_with_referrer
4+
columns:
5+
- name: block
6+
description: Block number in which this event occurred
7+
config:
8+
meta: {}
9+
tags: []
10+
- name: block_number
11+
description: Block number as a high-precision numeric value
12+
config:
13+
meta: {}
14+
tags: []
15+
- name: transaction_hash
16+
description: Hash of the transaction that emitted this event
17+
config:
18+
meta: {}
19+
tags: []
20+
- name: contract_id
21+
description: Address of the contract that emitted the event
22+
config:
23+
meta: {}
24+
tags: []
25+
- name: borrower
26+
description: Address of the borrower
27+
config:
28+
meta: {}
29+
tags: []
30+
- name: last_interest_update_time
31+
description: Timestamp of the last interest update
32+
config:
33+
meta: {}
34+
tags: []
35+
- name: _gs_chain
36+
description: Chain where the event originated, e.g., 'mezo'
37+
config:
38+
meta: {}
39+
tags: []
40+
- name: _gs_gid
41+
description: Unique identifier from Goldsky for the event
42+
config:
43+
meta: {}
44+
tags: []
45+
- name: record_timestamp
46+
description: Timestamp of the event formatted as a datetime
47+
config:
48+
meta: {}
49+
tags: []
50+
- name: operation
51+
description: Type of operation performed on the trove
52+
config:
53+
meta: {}
54+
tags: []
55+
- name: principal
56+
description: Principal debt amount (normalized currency)
57+
config:
58+
meta: {}
59+
tags: []
60+
- name: interest
61+
description: Interest amount (normalized currency)
62+
config:
63+
meta: {}
64+
tags: []
65+
- name: collateral
66+
description: Collateral amount (normalized currency)
67+
config:
68+
meta: {}
69+
tags: []
70+
- name: stake
71+
description: Stake amount (normalized currency)
72+
config:
73+
meta: {}
74+
tags: []
75+
- name: currency_conversion_timestamp
76+
description: ''
77+
config:
78+
meta: {}
79+
tags: []
80+
- name: collateral_usd_value
81+
description: ''
82+
config:
83+
meta: {}
84+
tags: []
85+
- name: collateral_ratio
86+
description: ''
87+
config:
88+
meta: {}
89+
tags: []
90+
- name: previous_principal_value
91+
description: ''
92+
config:
93+
meta: {}
94+
tags: []
95+
- name: previous_collateral_value
96+
description: ''
97+
config:
98+
meta: {}
99+
tags: []
100+
- name: adjustment_type_principal
101+
description: ''
102+
config:
103+
meta: {}
104+
tags: []
105+
- name: adjustment_type_collateral
106+
description: ''
107+
config:
108+
meta: {}
109+
tags: []
110+
- name: is_in_graph
111+
description: ''
112+
config:
113+
meta: {}
114+
tags: []
115+
- name: canonical_segment_id
116+
description: >-
117+
The fully-merged Segment ID (the profile Segment now understands any events or identifiers to
118+
map to).
119+
config:
120+
meta: {}
121+
tags: []
122+
- name: referrer_id
123+
description: Surrogate key for the channel grouping, generated from referrer source + medium.
124+
config:
125+
meta: {}
126+
tags: []
127+
data_type: STRING
128+
data_tests:
129+
- not_null
130+
- name: referrer_source
131+
data_type: string
132+
config:
133+
meta: {}
134+
tags: []
135+
description: The marketing source (e.g., google, newsletter) from which the user first
136+
arrived.
137+
- name: referrer_medium
138+
data_type: string
139+
config:
140+
meta: {}
141+
tags: []
142+
description: The marketing medium (e.g., cpc, email, referral) of the user’s first
143+
interaction.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
with
2+
donated as (select * from {{ ref("int_goldsky_market_mezo__donated_graph") }}),
3+
4+
first_touch_point as (
5+
select * from {{ ref("int_segment__sessions_first_touch_point") }}
6+
),
7+
8+
filtered_donated as (
9+
select
10+
d.*,
11+
coalesce(f.referrer_id, 'unknown') as referrer_id,
12+
coalesce(f.referrer_source, 'unknown') as referrer_source,
13+
coalesce(f.referrer_medium, 'unknown') as referrer_medium
14+
from donated as d
15+
left join
16+
first_touch_point as f on d.canonical_segment_id = f.canonical_segment_id
17+
)
18+
19+
select *
20+
from filtered_donated
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
version: 2
2+
models:
3+
- name: int_goldsky_market_mezo__donated_graph_with_referrer
4+
columns:
5+
- name: block
6+
description: Block number in which this event occurred
7+
config:
8+
meta: {}
9+
tags: []
10+
- name: block_number
11+
description: Block number as a high-precision numeric value
12+
config:
13+
meta: {}
14+
tags: []
15+
- name: transaction_hash
16+
description: Hash of the transaction that emitted this event
17+
config:
18+
meta: {}
19+
tags: []
20+
- name: contract_id
21+
description: Address of the contract that emitted the event
22+
config:
23+
meta: {}
24+
tags: []
25+
- name: donor
26+
description: Address of the donor
27+
config:
28+
meta: {}
29+
tags: []
30+
- name: beneficiary_id
31+
description: ID of the beneficiary
32+
config:
33+
meta: {}
34+
tags: []
35+
- name: _gs_chain
36+
description: Chain where the event originated, e.g., 'mezo'
37+
config:
38+
meta: {}
39+
tags: []
40+
- name: _gs_gid
41+
description: Unique identifier from Goldsky for the event
42+
config:
43+
meta: {}
44+
tags: []
45+
- name: record_timestamp
46+
description: Timestamp of the event formatted as a datetime
47+
config:
48+
meta: {}
49+
tags: []
50+
- name: amount
51+
description: Amount that was donated (normalized currency)
52+
config:
53+
meta: {}
54+
tags: []
55+
- name: recipient
56+
description: Address of the recipient
57+
config:
58+
meta: {}
59+
tags: []
60+
- name: is_in_graph
61+
description: ''
62+
config:
63+
meta: {}
64+
tags: []
65+
- name: canonical_segment_id
66+
description: >-
67+
The fully-merged Segment ID (the profile Segment now understands any events or identifiers to
68+
map to).
69+
config:
70+
meta: {}
71+
tags: []
72+
- name: referrer_id
73+
description: Surrogate key for the channel grouping, generated from referrer source + medium.
74+
config:
75+
meta: {}
76+
tags: []
77+
data_type: STRING
78+
data_tests:
79+
- not_null
80+
- name: referrer_source
81+
data_type: string
82+
config:
83+
meta: {}
84+
tags: []
85+
description: The marketing source (e.g., google, newsletter) from which the user first
86+
arrived.
87+
- name: referrer_medium
88+
data_type: string
89+
config:
90+
meta: {}
91+
tags: []
92+
description: The marketing medium (e.g., cpc, email, referral) of the user’s first
93+
interaction.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
with
2+
orders as (select * from {{ ref("int_goldsky_market_mezo__order_placed_graph") }}),
3+
4+
first_touch_point as (
5+
select * from {{ ref("int_segment__sessions_first_touch_point") }}
6+
),
7+
8+
filtered_order as (
9+
select
10+
o.*,
11+
coalesce(f.referrer_id, 'unknown') as referrer_id,
12+
coalesce(f.referrer_source, 'unknown') as referrer_source,
13+
coalesce(f.referrer_medium, 'unknown') as referrer_medium
14+
from orders as o
15+
left join
16+
first_touch_point as f on o.canonical_segment_id = f.canonical_segment_id
17+
)
18+
19+
select *
20+
from filtered_order

0 commit comments

Comments
 (0)