This repository has been archived by the owner on Jan 10, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ad.view.lkml
132 lines (114 loc) · 2.42 KB
/
ad.view.lkml
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
include: "adset.view"
include: "fivetran_base.view"
explore: ad_fb_adapter {
view_name: ad
from: ad_fb_adapter
hidden: yes
join: adset {
from: adset_fb_adapter
type: left_outer
sql_on: ${ad.adset_id} = ${adset.id} ;;
relationship: many_to_one
}
join: campaign {
from: campaign_fb_adapter
type: left_outer
sql_on: ${ad.campaign_id} = ${campaign.id} ;;
relationship: many_to_one
}
join: account {
from: account_fb_adapter
type: left_outer
sql_on: ${ad.account_id} = ${account.id} ;;
relationship: many_to_one
}
}
view: ad_fb_adapter {
extends: [fivetran_base_fb_adapter, facebook_ads_config]
derived_table: {
sql:
(
SELECT ad_history.* FROM `{{ ad.facebook_ad_account_schema._sql }}.ad_history` as ad_history
INNER JOIN (
SELECT
id, max(_fivetran_synced) as max_fivetran_synced
FROM `{{ ad.facebook_ad_account_schema._sql }}.ad_history`
GROUP BY id) max_ad_history
ON max_ad_history.id = ad_history.id
AND max_ad_history.max_fivetran_synced = ad_history._fivetran_synced
) ;;
}
dimension: id {
hidden: yes
sql: CAST(${TABLE}.id AS STRING) ;;
}
dimension: account_id {
hidden: yes
type: number
sql: ${TABLE}.account_id ;;
}
dimension: adset_id {
hidden: yes
type: number
sql: ${TABLE}.ad_set_id ;;
}
dimension: bid_amount {
hidden: yes
type: number
sql: ${TABLE}.bid_amount ;;
}
dimension: bid_type {
hidden: yes
type: string
sql: ${TABLE}.bid_type ;;
}
dimension: campaign_id {
hidden: yes
type: number
sql: ${TABLE}.campaign_id ;;
}
dimension: configured_status {
hidden: yes
type: string
sql: ${TABLE}.configured_status ;;
}
dimension_group: created {
hidden: yes
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.created_time ;;
}
dimension: creative_id {
hidden: yes
type: number
sql: ${TABLE}.creative_id ;;
}
dimension: effective_status {
hidden: yes
type: string
sql: ${TABLE}.effective_status ;;
}
dimension: status_active {
hidden: yes
type: yesno
sql: ${effective_status} = "ACTIVE" ;;
}
dimension: name {
hidden: yes
type: string
sql: ${TABLE}.name ;;
}
dimension: status {
hidden: yes
type: string
sql: ${TABLE}.status ;;
}
}