-
Notifications
You must be signed in to change notification settings - Fork 1
/
tasman_mta__attributed_conversions.sql
56 lines (47 loc) · 1.61 KB
/
tasman_mta__attributed_conversions.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
{{
config(
materialized='table',
snowflake_warehouse=get_warehouse()
)
}}
with
conversion_events as (
select * from {{ ref('tasman_mta__filtered_conversion_events') }}
),
attributed_touches as (
select * from {{ ref('tasman_mta__attributed_touches') }}
),
joined_conversion_events as (
select
{{ generate_surrogate_key([
'attributed_touches.model_id',
'conversion_events.model_id',
'attributed_touches.touch_event_id',
'conversion_events.conversion_event_id'
]) }} as surrogate_key,
conversion_events.conversion_user_id,
conversion_events.conversion_event_id,
conversion_events.conversion_timestamp,
conversion_events.model_id,
conversion_events.conversion_category,
attributed_touches.touch_event_id,
attributed_touches.touch_timestamp,
attributed_touches.touch_user_id,
attributed_touches.touch_category,
attributed_touches.att_window,
attributed_touches.convert_touch_count,
attributed_touches.convert_seq_up,
attributed_touches.convert_seq_down,
attributed_touches.interval_pre,
attributed_touches.interval_post,
attributed_touches.interval_convert,
attributed_touches.spec,
attributed_touches.conversion_share
from
conversion_events
left join
attributed_touches
on conversion_events.conversion_event_id = attributed_touches.conversion_event_id
and conversion_events.model_id = attributed_touches.model_id
)
select * from joined_conversion_events