This repository has been archived by the owner on Feb 28, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
campaign.view.lkml
136 lines (116 loc) · 2.55 KB
/
campaign.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
133
134
135
136
include: "account.view.lkml"
include: "stitch_base.view.lkml"
explore: campaign_nested_joins_base {
extension: required
join: campaign__ads__data {
view_label: "campaign: Ads Data"
sql_on: ${campaign.id} = ${campaign__ads__data.id} ;;
relationship: one_to_many
}
join: campaign__ads {
view_label: "campaign: Ads"
sql_on: ${campaign.id} = ${campaign__ads.id} ;;
relationship: one_to_one
}
}
explore: campaign_fb_adapter {
persist_with: facebook_ads_etl_datagroup
view_name: campaign
from: campaign_fb_adapter
extends: [campaign_nested_joins_base]
hidden: yes
join: account {
from: fb_account
type: left_outer
sql_on: '1' = ${account.id} ;;
relationship: many_to_one
}
}
view: campaign_fb_adapter {
extends: [stitch_base, facebook_ads_config]
# sql_table_name: {{ facebook_ads_schema._sql }}.facebook_campaigns_{{ facebook_account_id._sql }} ;;
sql_table_name: (
SELECT campaigns.*
FROM {{ facebook_ads_schema._sql }}.facebook_campaigns_{{ facebook_account_id._sql }} AS campaigns
INNER JOIN (
SELECT
MAX(_sdc_sequence) AS seq
, id
FROM {{ facebook_ads_schema._sql }}.facebook_campaigns_{{ facebook_account_id._sql }}
GROUP BY id
) AS max_campaigns
ON campaigns.id = max_campaigns.id
AND campaigns._sdc_sequence = max_campaigns.seq
) ;;
dimension: id {
hidden: yes
primary_key: yes
type: string
}
dimension: account_id {
hidden: yes
type: string
}
dimension: ads {
hidden: yes
}
dimension: buying_type {
type: string
}
dimension: effective_status {
type: string
hidden: yes
}
dimension: status_active {
type: yesno
sql: ${effective_status} = 'ACTIVE' ;;
}
dimension: name {
type: string
hidden: yes
}
dimension: objective {
type: string
hidden: yes
}
dimension: start_date {
sql: 'NA'::text ;;
}
dimension_group: updated {
hidden: yes
type: time
timeframes: [
raw,
time,
date,
week,
month,
quarter,
year
]
sql: ${TABLE}.updated_time ;;
}
}
view: campaign__ads__data {
extends: [stitch_base, facebook_ads_config]
sql_table_name: {{ facebook_ads_schema._sql }}."facebook_campaigns_{{ facebook_account_id._sql }}__ads__data" ;;
dimension: id {
hidden: yes
primary_key: yes
type: string
}
}
view: campaign__ads {
derived_table: {
sql:
SELECT
0 as id,
'NA'::text as data;;
}
dimension: data {
hidden: yes
}
dimension: id {
hidden: yes
}
}