Fivetran Linkedin

We display the source tables from the data warehouses to model.

linkedin_account_history_data (first 100 rows)

id last_modified_time created_time name currency version_tag
0 507515057 2020-10-12 19:05:20.398 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 55
1 507515057 2020-10-19 10:50:13.021 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 56
2 507515057 2020-10-12 10:50:12.579 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 50
3 507515057 2020-09-22 13:26:56.231 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 49
4 507515057 2020-08-24 12:22:01.025 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 45
5 507515057 2020-08-14 02:32:45.713 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 41
6 507515057 2020-10-23 15:09:38.215 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 57
7 507515057 2020-10-29 11:40:16.413 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 58
8 507515057 2020-09-20 10:50:04.290 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 48
9 507515057 2020-08-19 11:25:28.265 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 43
10 507515057 2020-06-26 15:43:20.472 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 40
11 507515057 2020-08-31 10:50:11.537 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 46
12 507515057 2020-08-22 10:50:20.513 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 44
13 507515057 2020-09-01 16:58:29.443 2017-06-07 22:44:32 p6zp17DVJVjAD3VAr1btVw== USD 47

linkedin_ad_analytics_by_campaign_data (first 100 rows)

campaign_id day_ action_clicks ad_unit_clicks approximate_unique_impressions card_clicks card_impressions clicks comment_likes comments company_page_clicks conversion_value_in_local_currency cost_in_local_currency cost_in_usd external_website_conversions external_website_post_click_conversions external_website_post_view_conversions follows full_screen_plays impressions landing_page_clicks lead_generation_mail_contact_info_shares lead_generation_mail_interested_clicks likes one_click_lead_form_opens one_click_leads opens other_engagements shares text_url_clicks total_engagements video_completions video_first_quartile_completions video_midpoint_completions video_starts video_third_quartile_completions video_views viral_card_clicks viral_card_impressions viral_clicks viral_comment_likes viral_comments viral_company_page_clicks viral_external_website_conversions viral_external_website_post_click_conversions viral_external_website_post_view_conversions viral_follows viral_full_screen_plays viral_impressions viral_landing_page_clicks viral_likes viral_one_click_lead_form_opens viral_one_click_leads viral_other_engagements viral_shares viral_total_engagements viral_video_completions viral_video_first_quartile_completions viral_video_midpoint_completions viral_video_starts viral_video_third_quartile_completions viral_video_views
0 148633856 2020-04-06 00:00:00 NaN NaN 0 NaN 0 18 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 18 0 NaN NaN 18 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
1 148633856 2020-04-03 00:00:00 NaN NaN 0 NaN 0 18 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 18 0 NaN NaN 18 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
2 148633856 2020-03-28 00:00:00 1.0 NaN 125 NaN 0 51 0 0.0 NaN 0 50.20 50.20 0 NaN 0.0 NaN NaN 125.0 1.0 0 0 NaN 0.0 NaN 51 0 0.0 NaN 52 0.0 NaN 0.0 NaN NaN 0 0.0 NaN 0 NaN NaN 0.0 NaN 0 0.0 0 0.0 0 0.0 0 0 NaN 0 0.0 0.0 0 0 0 0.0 NaN 0
3 148633856 2020-03-23 00:00:00 1.0 NaN 133 NaN 0 52 0 0.0 NaN 0 50.31 50.31 0 NaN 0.0 NaN NaN 143.0 1.0 0 0 NaN 0.0 NaN 52 0 0.0 NaN 53 0.0 NaN 0.0 NaN NaN 0 0.0 NaN 0 NaN NaN 0.0 NaN 0 0.0 0 0.0 0 0.0 0 0 NaN 0 0.0 0.0 0 0 0 0.0 NaN 0
4 148633856 2020-03-27 00:00:00 0.0 NaN 119 NaN 0 59 0 0.0 NaN 0 50.43 50.43 0 NaN 0.0 NaN NaN 126.0 0.0 0 0 NaN 0.0 NaN 59 0 0.0 NaN 59 0.0 NaN 0.0 NaN NaN 0 0.0 NaN 0 NaN NaN 0.0 NaN 0 0.0 0 0.0 0 0.0 0 0 NaN 0 0.0 0.0 0 0 0 0.0 NaN 0
5 148633856 2020-03-31 00:00:00 2.0 NaN 125 NaN 0 85 0 0.0 NaN 0 50.07 50.07 0 NaN 0.0 NaN NaN 125.0 2.0 0 0 NaN 0.0 NaN 85 0 0.0 NaN 87 0.0 NaN 0.0 NaN NaN 0 0.0 NaN 0 NaN NaN 0.0 NaN 0 0.0 0 0.0 0 0.0 0 0 NaN 0 0.0 0.0 0 0 0 0.0 NaN 0
6 148633856 2020-03-26 00:00:00 2.0 0.0 67 0.0 0 37 0 0.0 0.0 0 30.12 30.12 0 0.0 0.0 0.0 0.0 75.0 3.0 0 0 0.0 0.0 0.0 37 0 0.0 1.0 40 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
7 148633856 2020-03-24 00:00:00 0.0 0.0 143 0.0 0 52 0 0.0 0.0 0 50.31 50.31 0 0.0 0.0 0.0 0.0 143.0 1.0 0 0 0.0 0.0 0.0 52 0 0.0 1.0 53 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
8 148633856 2020-03-25 00:00:00 1.0 0.0 124 0.0 0 56 0 0.0 0.0 0 50.05 50.05 0 0.0 0.0 0.0 0.0 125.0 2.0 0 0 0.0 0.0 0.0 56 0 0.0 1.0 58 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
9 148633856 2020-03-29 00:00:00 2.0 0.0 125 0.0 0 68 0 0.0 0.0 0 50.16 50.16 0 0.0 0.0 0.0 0.0 125.0 3.0 0 0 0.0 0.0 0.0 68 0 0.0 1.0 71 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
10 148633856 2020-04-02 00:00:00 0.0 0.0 122 0.0 0 74 0 0.0 0.0 0 48.80 48.80 0 0.0 0.0 0.0 0.0 122.0 2.0 0 0 0.0 0.0 0.0 74 0 0.0 2.0 76 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
11 148633856 2020-04-01 00:00:00 0.0 0.0 120 0.0 0 79 0 0.0 0.0 0 50.13 50.13 0 0.0 0.0 0.0 0.0 125.0 2.0 0 0 0.0 0.0 0.0 79 0 0.0 2.0 81 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
12 148633856 2020-03-30 00:00:00 3.0 0.0 125 0.0 0 82 0 0.0 0.0 0 50.04 50.04 0 0.0 0.0 0.0 0.0 125.0 4.0 0 0 0.0 0.0 0.0 82 0 0.0 1.0 86 0.0 0.0 0.0 0.0 0.0 0 0.0 0.0 0 0.0 0.0 0.0 0.0 0 0.0 0 0.0 0 0.0 0 0 0.0 0 0.0 0.0 0 0 0 0.0 0.0 0
13 174096954 2021-05-25 00:00:00 NaN NaN 0 NaN 0 23 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 23 0 NaN NaN 23 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
14 174096954 2021-05-20 00:00:00 NaN NaN 0 NaN 0 35 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 35 0 NaN NaN 35 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
15 167276694 2020-10-22 00:00:00 NaN NaN 0 NaN 0 38 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 38 0 NaN NaN 38 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
16 174096954 2021-05-19 00:00:00 NaN NaN 0 NaN 0 43 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 43 0 NaN NaN 43 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
17 167276694 2020-11-03 00:00:00 NaN NaN 0 NaN 0 15 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 15 0 NaN NaN 15 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
18 165867684 2020-07-31 00:00:00 NaN NaN 0 NaN 0 17 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 17 0 NaN NaN 17 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0
19 165867684 2020-08-03 00:00:00 NaN NaN 0 NaN 0 17 0 NaN NaN 0 0.00 NaN 0 NaN NaN NaN NaN NaN NaN 0 0 NaN NaN NaN 17 0 NaN NaN 17 NaN NaN NaN NaN NaN 0 NaN NaN 0 NaN NaN NaN NaN 0 NaN 0 NaN 0 NaN 0 0 NaN 0 NaN NaN 0 0 0 NaN NaN 0

linkedin_ad_analytics_by_creative_data (first 100 rows)

creative_id day_ clicks impressions cost_in_local_currency cost_in_usd
0 112590914 2020-10-17 00:00:00 NaN NaN 0.0 NaN
1 95761876 2020-10-09 00:00:00 NaN NaN 0.0 NaN
2 102318493 2020-11-05 00:00:00 NaN NaN 0.0 NaN
3 95761676 2020-10-10 00:00:00 NaN NaN 0.0 NaN
4 104230363 2020-10-23 00:00:00 NaN NaN 0.0 NaN
5 112600554 2020-10-20 00:00:00 NaN NaN 0.0 NaN
6 95763356 2020-10-19 00:00:00 NaN NaN 0.0 NaN
7 70668606 2019-08-02 00:00:00 NaN 113.0 NaN 0.0
8 69776656 2019-07-14 00:00:00 NaN 15.0 NaN 0.0
9 70668676 2019-08-27 00:00:00 NaN 217.0 NaN 0.0
10 44900346 2018-05-30 00:00:00 NaN 249.0 NaN 0.0
11 81968486 2020-03-18 00:00:00 NaN 65.0 NaN 0.0
12 70668676 2019-08-02 00:00:00 NaN 221.0 NaN 0.0
13 81968486 2020-03-13 00:00:00 NaN 41.0 NaN 0.0
14 82056746 2020-03-16 00:00:00 NaN 9.0 NaN 0.0
15 44900356 2018-06-15 00:00:00 NaN 317.0 NaN 0.0
16 70669876 2019-08-15 00:00:00 NaN 109.0 NaN 0.0
17 84578906 2020-05-06 00:00:00 NaN 136.0 NaN 0.0
18 80494806 2020-02-22 00:00:00 NaN 207.0 NaN 0.0
19 84909276 2020-05-05 00:00:00 NaN 8.0 NaN 0.0
20 76339806 2019-12-29 00:00:00 NaN 186.0 NaN 0.0
21 82056546 2020-04-01 00:00:00 NaN 425.0 NaN 0.0
22 44901886 2018-06-01 00:00:00 NaN 17.0 NaN 0.0
23 70668856 2019-07-31 00:00:00 NaN 144.0 NaN 0.0
24 84594916 2020-05-07 00:00:00 NaN 51.0 NaN 0.0
25 70668676 2019-09-04 00:00:00 NaN 31.0 NaN 0.0
26 44900366 2017-07-25 00:00:00 NaN 439.0 NaN 0.0
27 80494706 2020-02-21 00:00:00 NaN 1.0 NaN 0.0
28 44901876 2017-07-17 00:00:00 NaN 121.0 NaN 0.0
29 81968566 2020-03-21 00:00:00 NaN 54.0 NaN 0.0
30 44900356 2017-06-11 00:00:00 NaN 311.0 NaN 0.0
31 84897806 2020-05-21 00:00:00 NaN 329.0 NaN 0.0
32 70669876 2019-08-22 00:00:00 NaN 20.0 NaN 0.0
33 44900336 2018-07-28 00:00:00 NaN 181.0 NaN 0.0
34 44900356 2017-07-25 00:00:00 NaN 391.0 NaN 0.0
35 102326993 2020-08-12 00:00:00 NaN NaN 0.0 NaN
36 111449024 2020-10-06 00:00:00 NaN NaN 0.0 NaN
37 109754844 2020-09-16 00:00:00 NaN NaN 0.0 NaN
38 111024974 2020-09-28 00:00:00 NaN NaN 0.0 NaN
39 103117663 2020-08-06 00:00:00 NaN NaN 0.0 NaN
40 107328744 2020-10-24 00:00:00 NaN NaN 0.0 NaN
41 95763826 2020-10-16 00:00:00 NaN NaN 0.0 NaN
42 94954376 2020-10-17 00:00:00 NaN NaN 0.0 NaN
43 95762316 2020-10-11 00:00:00 NaN NaN 0.0 NaN
44 44900366 2018-07-04 00:00:00 NaN 850.0 NaN 0.0
45 83878136 2020-04-20 00:00:00 NaN 22.0 NaN 0.0
46 70668606 2019-08-18 00:00:00 NaN 5.0 NaN 0.0
47 44900336 2018-05-27 00:00:00 NaN 309.0 NaN 0.0
48 84092676 2020-04-29 00:00:00 NaN 8.0 NaN 0.0
49 70668856 2019-08-29 00:00:00 NaN 9.0 NaN 0.0
50 70668306 2019-08-04 00:00:00 NaN 61.0 NaN 0.0
51 69775486 2019-07-24 00:00:00 NaN 1075.0 NaN 0.0
52 69776656 2019-08-22 00:00:00 NaN 84.0 NaN 0.0
53 48046336 2017-10-19 00:00:00 NaN 12.0 NaN 0.0
54 55220314 2018-06-04 00:00:00 NaN 54.0 NaN 0.0
55 44900356 2018-06-04 00:00:00 NaN 407.0 NaN 0.0
56 82056656 2020-03-16 00:00:00 NaN 14.0 NaN 0.0
57 44900356 2018-05-29 00:00:00 NaN 481.0 NaN 0.0
58 44901856 2018-05-13 00:00:00 NaN 109.0 NaN 0.0
59 70668676 2019-08-29 00:00:00 NaN 90.0 NaN 0.0
60 48046326 2018-08-11 00:00:00 NaN 29.0 NaN 0.0
61 70668606 2019-08-25 00:00:00 NaN 10.0 NaN 0.0
62 70669236 2019-08-11 00:00:00 NaN 20.0 NaN 0.0
63 81968586 2020-04-16 00:00:00 NaN 142.0 NaN 0.0
64 55220334 2018-06-11 00:00:00 NaN 721.0 NaN 0.0
65 70669876 2019-08-18 00:00:00 NaN 4.0 NaN 0.0
66 48046336 2017-10-22 00:00:00 NaN 2.0 NaN 0.0
67 44901866 2018-06-13 00:00:00 NaN 102.0 NaN 0.0
68 55220314 2018-05-28 00:00:00 NaN 111.0 NaN 0.0
69 70668606 2019-08-30 00:00:00 NaN 21.0 NaN 0.0
70 69776656 2019-08-02 00:00:00 NaN 90.0 NaN 0.0
71 44901866 2018-06-20 00:00:00 NaN 72.0 NaN 0.0
72 48046336 2018-07-13 00:00:00 NaN 2.0 NaN 0.0
73 76339806 2019-11-21 00:00:00 NaN 638.0 NaN 0.0
74 107427114 2020-09-17 00:00:00 NaN NaN 0.0 NaN
75 107780874 2020-08-03 00:00:00 NaN NaN 0.0 NaN
76 103860724 2020-07-22 00:00:00 NaN NaN 0.0 NaN
77 94336026 2020-09-21 00:00:00 NaN NaN 0.0 NaN
78 109331754 2020-09-01 00:00:00 NaN NaN 0.0 NaN
79 107328014 2020-09-02 00:00:00 NaN NaN 0.0 NaN
80 107426034 2020-07-24 00:00:00 NaN NaN 0.0 NaN
81 107426034 2020-09-11 00:00:00 NaN NaN 0.0 NaN
82 104229493 2020-10-21 00:00:00 NaN NaN 0.0 NaN
83 104230513 2020-10-27 00:00:00 NaN NaN 0.0 NaN
84 109947744 2020-10-21 00:00:00 NaN NaN 0.0 NaN
85 104229703 2020-10-28 00:00:00 NaN NaN 0.0 NaN
86 112487464 2020-10-08 00:00:00 NaN NaN 0.0 NaN
87 70669876 2019-08-04 00:00:00 NaN 20.0 NaN 0.0
88 44901856 2018-06-05 00:00:00 NaN 267.0 NaN 0.0
89 44901886 2018-05-20 00:00:00 NaN 848.0 NaN 0.0
90 80494736 2020-02-25 00:00:00 NaN 9.0 NaN 0.0
91 44901866 2018-05-12 00:00:00 NaN 90.0 NaN 0.0
92 44901856 2018-05-27 00:00:00 NaN 175.0 NaN 0.0
93 81708396 2020-03-09 00:00:00 NaN 58.0 NaN 0.0
94 60400066 2018-11-24 00:00:00 NaN 73.0 NaN 0.0
95 44901866 2017-07-04 00:00:00 NaN 1424.0 NaN 0.0
96 44900346 2018-06-07 00:00:00 NaN 224.0 NaN 0.0
97 70669196 2019-08-24 00:00:00 NaN 3.0 NaN 0.0
98 55220314 2018-05-27 00:00:00 NaN 111.0 NaN 0.0
99 48046336 2018-07-09 00:00:00 NaN 1.0 NaN 0.0

linkedin_campaign_group_history_data (first 100 rows)

id last_modified_time account_id created_time name
0 602751036 2018-09-06 16:52:33.720 507515057 2018-09-06 16:31:50 f7l0OENVPPPqyXqP9TMSCw==
1 602018326 2020-06-05 19:05:08 507515057 2018-05-18 00:49:23 9eWX62RMpoodTvMVlpsIQw==
2 602018326 2020-09-10 18:09:39 507515057 2018-05-18 00:49:23 9eWX62RMpoodTvMVlpsIQw==
3 600268686 2017-06-07 22:44:32 507515057 2017-06-07 22:44:32 wpZy9D1VMXKii8s1G/8Umw==

linkedin_campaign_history_data (first 100 rows)

id last_modified_time account_id campaign_group_id created_time name version_tag
0 132822896 2019-09-14 17:53:17.393 507515057 600268686 2018-07-25 14:59:12 CY9rzUYh03PK3k6DJie09g== 33
1 132822186 2019-09-14 17:53:19.538 507515057 600268686 2018-07-25 14:34:44 A16SHlVkEdYzDYcuKAyKdQ== 34
2 132866546 2019-09-14 17:52:40.697 507515057 600268686 2018-07-27 20:51:22 lRq7HdKfzTQkOokgrw809Q== 33
3 147624636 2020-03-31 23:49:40.206 507515057 600268686 2020-02-17 08:55:44 vqkXsHSguUTB/tNx2xICkQ== 73
4 147624646 2020-03-31 23:49:40.206 507515057 600268686 2020-02-17 08:56:24 p878CnpgR+9mdq58o3nkhg== 64
5 148633856 2020-03-31 23:49:40.206 507515057 600268686 2020-02-17 08:57:41 kUcfickNRhqYy57PLNwqTQ== 66
6 148633856 2020-07-14 11:54:05 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 125
7 162286513 2020-10-19 08:00:30 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 170
8 162286513 2020-10-19 15:20:48 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 171
9 162286513 2020-10-18 10:07:35 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 167
10 162286513 2020-10-16 16:44:41 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 163
11 174096954 2020-10-17 23:08:54 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 166
12 162286513 2020-10-17 02:47:20 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 164
13 162286513 2020-08-07 09:26:07 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 160
14 162286513 2020-10-22 21:56:41 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 175
15 162286513 2020-08-06 21:10:53 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 145
16 167276694 2020-07-21 00:57:53 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 141
17 162286513 2020-07-13 20:22:54 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 124
18 162286513 2020-08-06 17:12:01 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 144
19 162286513 2020-10-16 07:40:36 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 162
20 162286513 2020-10-17 11:38:02 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 165
21 162286513 2020-10-15 16:48:15 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 161
22 162286513 2020-10-18 20:13:44 507515057 600268686 2020-05-06 20:41:33 +A+12nfTw2I6vA3PNV0GDw== 168
23 165867684 2020-07-13 19:55:36 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 126
24 162286313 2020-08-24 21:06:55 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 206
25 162286313 2020-10-16 16:20:40 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 226
26 162286313 2020-10-17 04:59:30 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 227
27 162286313 2020-10-16 06:25:34 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 225
28 162286313 2020-07-26 16:24:19 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 152
29 162286313 2020-07-14 11:27:20 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 127
30 162286313 2020-08-23 01:18:19 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 202
31 162286313 2020-09-11 00:16:38 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 223
32 162286313 2020-07-26 00:53:40 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 151
33 162286313 2020-07-27 09:37:28 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 153
34 162286313 2020-07-24 05:58:28 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 148
35 162286313 2020-09-09 16:16:40 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 213
36 162286313 2020-07-30 20:32:59 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 159
37 162286313 2020-10-15 16:48:11 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 224
38 162286313 2020-10-22 21:55:05 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 237
39 162286313 2020-08-20 21:50:50 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 198
40 162286313 2020-07-28 01:22:33 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 154
41 162286313 2020-07-30 09:34:24 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 158
42 162286313 2020-07-24 18:36:37 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 149
43 162286313 2020-07-29 01:32:28 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 156
44 162286313 2020-07-25 11:39:44 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 150
45 162286313 2020-10-18 19:52:27 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 231
46 162286313 2020-07-22 10:11:24 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 145
47 162286313 2020-08-19 03:16:42 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 195
48 162286313 2020-08-20 07:35:29 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 197
49 162286313 2020-07-21 18:43:55 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 144
50 162286313 2020-07-28 13:19:59 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 155
51 162286313 2020-08-23 15:07:52 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 203
52 162286313 2020-07-31 12:30:00 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 160
53 162286313 2020-07-23 03:17:43 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 146
54 162286313 2020-08-19 16:10:52 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 196
55 162286313 2020-10-17 22:05:52 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 229
56 162286313 2020-10-19 08:49:28 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 233
57 162286313 2020-10-19 15:20:42 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 234
58 162286313 2020-08-25 03:59:10 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 208
59 162286313 2020-09-01 16:54:53 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 210
60 162286313 2020-07-29 14:42:05 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 157
61 162286313 2020-08-21 15:48:02 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 199
62 162286313 2020-10-17 12:21:20 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 228
63 162286313 2020-08-24 10:25:27 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 205
64 162286313 2020-07-23 16:12:35 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 147
65 162286313 2020-09-02 00:16:42 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 211
66 162286313 2020-07-21 00:58:26 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 143
67 162286313 2020-10-18 10:30:01 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 230
68 162286313 2020-08-22 11:22:38 507515057 600268686 2020-05-06 20:37:36 XjFwQcqOj/a3ca8uS3EUzA== 201
69 162288753 2020-09-25 17:32:04 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 102
70 162288753 2020-09-22 15:02:04 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 98
71 162288753 2020-09-30 17:26:32 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 109
72 162288753 2020-08-29 07:20:19 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 55
73 162288753 2020-09-18 02:11:54 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 89
74 162288753 2020-09-14 10:38:17 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 83
75 162288753 2020-10-04 04:07:29 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 114
76 162288753 2020-09-25 01:29:52 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 101
77 162288753 2020-09-27 09:07:13 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 104
78 162288753 2020-09-07 01:45:26 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 71
79 162288753 2020-09-28 04:39:20 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 105
80 162288753 2020-09-15 15:09:44 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 85
81 162288753 2020-09-18 17:05:50 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 90
82 162288753 2020-10-05 14:35:47 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 116
83 162288753 2020-10-04 23:47:19 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 115
84 162288753 2020-09-02 03:27:14 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 63
85 162288753 2020-09-05 19:12:44 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 69
86 162288753 2020-09-06 08:32:32 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 70
87 162288753 2020-08-31 17:27:01 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 60
88 162288753 2020-09-21 07:08:26 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 95
89 162288753 2020-10-02 19:42:11 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 112
90 162288753 2020-09-19 23:42:57 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 93
91 162288753 2020-09-23 07:32:14 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 99
92 162288753 2020-09-08 19:42:07 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 74
93 162288753 2020-09-22 01:24:42 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 97
94 162288753 2020-09-17 10:15:03 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 88
95 162288753 2020-09-13 02:47:37 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 81
96 162288753 2020-10-03 10:28:28 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 113
97 162288753 2020-09-20 15:31:37 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 94
98 162288753 2020-09-24 07:20:21 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 100
99 162288753 2020-08-28 14:56:39 507515057 600268686 2020-05-06 21:23:28 aKI/VAmh+UP8KcE2Q5bXRg== 54

linkedin_creative_history_data (first 100 rows)

id last_modified_at created_at campaign_id intended_status click_uri
0 112590914 2020-07-01 00:32:56 2018-05-24 00:38:47 131580446 CANCELED https://google.com
1 95761876 2020-07-01 00:32:56 2018-05-18 01:04:02 131454616 CANCELED None
2 102318493 2020-09-10 18:29:16 2020-09-10 18:08:57 167276694 ACTIVE None
3 95761676 2020-07-27 15:19:33 2020-07-22 19:28:31 165867684 ACTIVE None
4 104230363 2020-07-22 19:28:31 2020-07-22 19:28:31 165867684 DRAFT None
5 112600554 2020-05-08 11:37:43 2020-05-08 09:34:15 162464924 ACTIVE None
6 95763356 2020-05-12 15:39:25 2020-05-12 14:08:40 162557074 ACTIVE None
7 70668606 2020-07-01 00:32:56 2018-05-18 01:09:08 131454826 CANCELED None
8 69776656 2020-03-23 14:52:29 2020-03-20 18:55:40 148633856 ACTIVE None
9 70668676 2020-07-01 00:32:56 2018-05-24 00:47:40 131580546 CANCELED None
10 44900346 2020-03-24 18:05:27 2020-03-24 17:56:49 148711996 ACTIVE None
11 81968486 2018-02-12 10:09:41 2017-06-08 21:46:06 125600246 ACTIVE None
12 70668676 2018-02-12 10:09:19 2017-06-08 21:46:06 125600246 ACTIVE None
13 81968486 2018-02-12 10:09:56 2017-06-08 21:46:06 125600246 ACTIVE None
14 82056746 2018-02-12 10:09:27 2017-06-08 21:46:06 125600246 ACTIVE None
15 44900356 2020-07-23 17:22:59 2017-08-04 22:45:09 133160324 PAUSED None
16 70669876 2018-05-11 12:38:59 2017-08-04 22:45:09 133160324 ACTIVE None
17 84578906 2018-02-12 10:22:30 2017-06-08 22:29:09 125599426 ACTIVE None
18 80494806 2018-02-12 10:22:34 2017-06-08 22:29:09 125599426 ACTIVE None
19 84909276 2018-05-11 12:38:59 2017-08-04 22:45:09 133160324 ACTIVE None
20 76339806 2018-02-12 10:22:39 2017-06-08 22:29:09 125599426 ACTIVE None
21 82056546 2018-05-11 12:38:59 2017-08-04 22:45:09 133160324 ACTIVE None
22 44901886 2018-05-11 12:38:59 2017-08-04 22:45:09 133160324 ACTIVE None
23 70668856 2018-02-12 10:22:43 2017-06-08 22:29:09 125599426 ACTIVE None
24 84594916 2018-08-07 15:13:09 2017-10-10 16:49:38 127624356 PAUSED None
25 70668676 2018-08-31 20:21:58 2017-10-10 16:49:38 127624356 PAUSED None
26 44900366 2018-08-31 20:21:56 2017-10-10 16:49:38 127624356 PAUSED None
27 80494706 2018-04-19 01:01:41 2017-12-22 17:38:12 128806186 ACTIVE None
28 44901876 2018-04-20 16:09:25 2017-12-22 17:27:45 128806016 ACTIVE None
29 81968566 2018-04-20 20:54:43 2017-12-22 17:38:12 128806186 ACTIVE None
30 44900356 2018-04-20 20:54:36 2017-12-22 17:27:45 128806016 ACTIVE None
31 84897806 2018-07-28 18:42:52 2018-07-25 15:04:05 132822186 PAUSED None
32 70669876 2018-07-28 18:57:01 2018-07-28 18:48:26 132870856 ACTIVE None
33 44900336 2018-07-28 18:44:22 2018-07-28 18:38:10 132866546 ARCHIVED None
34 44900356 2018-09-10 23:06:50 2018-09-06 16:59:15 133672706 ACTIVE None
35 102326993 2018-09-10 17:55:24 2018-09-10 17:52:28 133728466 ACTIVE None
36 111449024 2018-09-10 23:18:06 2018-09-10 23:16:13 133736786 ACTIVE None
37 109754844 2018-09-13 18:01:26 2018-09-13 17:59:19 133822116 ACTIVE None
38 111024974 2018-10-08 17:51:55 2018-10-08 17:49:29 134383046 ACTIVE None
39 103117663 2018-10-08 17:55:09 2018-10-08 17:54:17 134383176 ACTIVE None
40 107328744 2018-11-14 21:16:03 2018-10-31 17:30:40 134988516 ACTIVE None
41 95763826 2018-11-23 12:57:25 2018-11-21 17:08:53 135583676 ACTIVE None
42 94954376 2018-12-10 18:03:37 2018-12-10 18:01:42 136022286 ACTIVE None
43 95762316 2019-01-08 17:52:12 2019-01-08 17:27:32 136508426 ACTIVE None
44 44900366 2019-01-08 18:00:10 2019-01-08 17:57:44 136509566 ACTIVE None
45 83878136 2019-01-11 21:06:51 2019-01-11 21:00:57 136598756 ACTIVE None
46 70668606 2019-01-17 22:39:37 2019-01-17 19:19:05 136746346 ACTIVE None
47 44900336 2019-02-20 23:02:25 2019-02-20 17:23:30 137527956 ACTIVE None
48 84092676 2019-02-21 17:53:26 2019-02-21 17:46:17 137559956 ACTIVE None
49 70668856 2019-03-04 19:37:29 2019-03-04 19:12:56 137824786 ACTIVE None
50 70668306 2019-04-29 17:21:39 2019-04-29 17:20:56 139304236 ACTIVE None
51 69775486 2019-04-29 17:45:59 2019-04-29 17:32:14 139304466 ACTIVE None
52 69776656 2019-05-08 18:31:04 2019-05-08 17:34:16 139548496 ACTIVE None
53 48046336 2019-05-09 15:47:39 2019-05-09 15:19:05 139581266 ACTIVE None
54 55220314 2019-05-10 19:24:18 2019-05-10 16:05:30 139619466 ACTIVE None
55 44900356 2019-05-17 16:53:00 2019-05-17 14:50:20 139812856 ACTIVE None
56 82056656 2019-06-03 20:44:36 2019-06-03 19:34:54 140203726 ACTIVE None
57 44900356 2019-06-03 20:59:59 2019-06-03 20:59:46 140206956 ACTIVE None
58 44901856 2019-06-14 17:17:25 2019-06-14 17:17:18 140506806 ACTIVE None
59 70668676 2019-07-01 20:07:24 2019-06-21 18:33:19 140715576 PAUSED None
60 48046326 2019-07-08 15:39:00 2019-07-08 15:16:08 141092076 ACTIVE None
61 70668606 2019-07-29 15:16:22 2019-07-08 15:13:19 141091746 ACTIVE None
62 70669236 2019-07-08 15:24:28 2019-07-08 15:24:18 141092526 ACTIVE None
63 81968586 2019-07-08 15:29:26 2019-07-08 15:29:15 141092656 ACTIVE None
64 55220334 2019-07-18 15:40:35 2019-07-18 15:40:03 141360566 ACTIVE None
65 70669876 2019-07-29 18:33:07 2019-07-29 18:33:05 141360566 ACTIVE None
66 48046336 2019-07-29 18:36:00 2019-07-29 18:35:50 141360566 ACTIVE None
67 44901866 2019-07-29 18:45:38 2019-07-29 18:37:21 141360566 ACTIVE None
68 55220314 2019-09-02 12:50:44 2019-07-29 18:40:24 141091746 ACTIVE None
69 70668606 2019-07-29 18:41:56 2019-07-29 18:41:41 141091746 ACTIVE None
70 69776656 2019-07-29 18:43:33 2019-07-29 18:43:04 141091746 ACTIVE None
71 44901866 2019-07-29 18:46:44 2019-07-29 18:46:41 141092526 ACTIVE None
72 48046336 2019-07-29 18:48:14 2019-07-29 18:48:12 141092526 ACTIVE None
73 76339806 2019-07-29 18:52:40 2019-07-29 18:52:24 141092526 ACTIVE None
74 107427114 2019-07-29 18:53:31 2019-07-29 18:53:27 141092656 ACTIVE None
75 107780874 2019-07-29 18:55:06 2019-07-29 18:54:42 141092656 ACTIVE None
76 103860724 2019-07-29 19:08:42 2019-07-29 19:08:28 141092656 ACTIVE None
77 94336026 2019-09-06 17:06:44 2019-09-06 16:54:36 142718926 ACTIVE None
78 109331754 2019-09-07 01:31:08 2019-09-06 18:47:11 142723626 ACTIVE None
79 107328014 2019-09-12 16:49:10 2019-09-12 16:48:25 142886156 ACTIVE None
80 107426034 2019-10-30 17:48:33 2019-10-30 17:47:59 144266096 ACTIVE None
81 107426034 2019-10-30 18:28:54 2019-10-30 18:28:17 144267636 ACTIVE None
82 104229493 2019-11-06 18:15:13 2019-11-06 18:14:42 144486446 ACTIVE None
83 104230513 2019-11-14 15:59:08 2019-11-14 15:58:40 144730056 ACTIVE None
84 109947744 2019-12-18 17:06:17 2019-12-18 16:13:57 146251416 ACTIVE None
85 104229703 2019-12-19 16:59:51 2019-12-19 15:42:00 146251626 ACTIVE None
86 112487464 2020-01-07 19:05:55 2020-01-07 19:05:17 146537336 ACTIVE None
87 70669876 2020-02-03 20:11:30 2020-02-03 20:10:59 147221246 ACTIVE None
88 44901856 2020-03-26 20:37:26 2020-03-26 20:37:02 148790486 ACTIVE None
89 44901886 2020-03-26 20:38:13 2020-03-26 20:37:44 148790536 ACTIVE None
90 80494736 2020-03-26 20:38:58 2020-03-26 20:38:25 148790586 ACTIVE None
91 44901866 2020-04-07 15:12:31 2020-04-07 15:10:41 149101206 ACTIVE None
92 44901856 2020-04-07 18:49:47 2020-04-07 15:24:12 149101696 ACTIVE None
93 81708396 2020-04-07 15:32:09 2020-04-07 15:31:39 149102126 ACTIVE None
94 60400066 2020-06-01 15:53:04 2020-04-28 15:27:36 149834446 PAUSED None
95 44901866 2020-05-26 11:11:58 2020-05-26 11:09:20 162905364 ACTIVE None
96 44900346 2020-08-21 21:15:10 2020-08-21 21:14:46 166816004 ACTIVE None
97 70669196 2020-08-21 21:15:47 2020-08-21 21:15:23 166816034 ACTIVE None
98 55220314 2020-08-21 21:16:11 2020-08-21 21:15:59 166816044 ACTIVE None
99 48046336 2020-08-21 21:17:17 2020-08-21 21:17:13 166816094 ACTIVE None
Source tables may have typos, unclear names, incorrect column types, etc. We clean these tables.

stg_linkedin_ad_analytics_by_campaign_data (first 100 rows)

action_button_clicks unique_impressions campaign_id card_impressions total_clicks comment_likes conversion_value_local cost_local cost_usd total_impressions landing_page_clicks lead_gen_mail_shares lead_gen_mail_clicks one_click_form_opens ad_opens other_engagements shares total_engagements video_views ad_unit_clicks card_clicks comments company_page_clicks date_ follows full_screen_plays likes one_click_leads text_url_clicks video_starts
0 NaN 0 148633856 0 18 0 0 0.00 NaN NaN NaN 0 0 NaN 18 0 NaN 18 0 None None None None 2020-04-06 None None None None None None
1 NaN 0 148633856 0 18 0 0 0.00 NaN NaN NaN 0 0 NaN 18 0 NaN 18 0 None None None None 2020-04-03 None None None None None None
2 1.0 125 148633856 0 51 0 0 50.20 50.20 125.0 1.0 0 0 0.0 51 0 0.0 52 0 None None 0.0 None 2020-03-28 None None None None None None
3 1.0 133 148633856 0 52 0 0 50.31 50.31 143.0 1.0 0 0 0.0 52 0 0.0 53 0 None None 0.0 None 2020-03-23 None None None None None None
4 0.0 119 148633856 0 59 0 0 50.43 50.43 126.0 0.0 0 0 0.0 59 0 0.0 59 0 None None 0.0 None 2020-03-27 None None None None None None
5 2.0 125 148633856 0 85 0 0 50.07 50.07 125.0 2.0 0 0 0.0 85 0 0.0 87 0 None None 0.0 None 2020-03-31 None None None None None None
6 2.0 67 148633856 0 37 0 0 30.12 30.12 75.0 3.0 0 0 0.0 37 0 0.0 40 0 0.0 0.0 0.0 0.0 2020-03-26 0.0 0.0 0.0 0.0 1.0 0.0
7 0.0 143 148633856 0 52 0 0 50.31 50.31 143.0 1.0 0 0 0.0 52 0 0.0 53 0 0.0 0.0 0.0 0.0 2020-03-24 0.0 0.0 0.0 0.0 1.0 0.0
8 1.0 124 148633856 0 56 0 0 50.05 50.05 125.0 2.0 0 0 0.0 56 0 0.0 58 0 0.0 0.0 0.0 0.0 2020-03-25 0.0 0.0 0.0 0.0 1.0 0.0
9 2.0 125 148633856 0 68 0 0 50.16 50.16 125.0 3.0 0 0 0.0 68 0 0.0 71 0 0.0 0.0 0.0 0.0 2020-03-29 0.0 0.0 0.0 0.0 1.0 0.0
10 0.0 122 148633856 0 74 0 0 48.80 48.80 122.0 2.0 0 0 0.0 74 0 0.0 76 0 0.0 0.0 0.0 0.0 2020-04-02 0.0 0.0 0.0 0.0 2.0 0.0
11 0.0 120 148633856 0 79 0 0 50.13 50.13 125.0 2.0 0 0 0.0 79 0 0.0 81 0 0.0 0.0 0.0 0.0 2020-04-01 0.0 0.0 0.0 0.0 2.0 0.0
12 3.0 125 148633856 0 82 0 0 50.04 50.04 125.0 4.0 0 0 0.0 82 0 0.0 86 0 0.0 0.0 0.0 0.0 2020-03-30 0.0 0.0 0.0 0.0 1.0 0.0
13 NaN 0 174096954 0 23 0 0 0.00 NaN NaN NaN 0 0 NaN 23 0 NaN 23 0 None None None None 2021-05-25 None None None None None None
14 NaN 0 174096954 0 35 0 0 0.00 NaN NaN NaN 0 0 NaN 35 0 NaN 35 0 None None None None 2021-05-20 None None None None None None
15 NaN 0 167276694 0 38 0 0 0.00 NaN NaN NaN 0 0 NaN 38 0 NaN 38 0 None None None None 2020-10-22 None None None None None None
16 NaN 0 174096954 0 43 0 0 0.00 NaN NaN NaN 0 0 NaN 43 0 NaN 43 0 None None None None 2021-05-19 None None None None None None
17 NaN 0 167276694 0 15 0 0 0.00 NaN NaN NaN 0 0 NaN 15 0 NaN 15 0 None None None None 2020-11-03 None None None None None None
18 NaN 0 165867684 0 17 0 0 0.00 NaN NaN NaN 0 0 NaN 17 0 NaN 17 0 None None None None 2020-07-31 None None None None None None
19 NaN 0 165867684 0 17 0 0 0.00 NaN NaN NaN 0 0 NaN 17 0 NaN 17 0 None None None None 2020-08-03 None None None None None None

stg_linkedin_ad_analytics_by_campaign_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_ad_analytics_by_campaign_data_removeWideColumns" AS (
    -- Remove wide columns with pattern. The regex and columns are:
    -- ^viral_.*$: viral_card_clicks, viral_card_impressions, viral_clicks, viral_comment_likes, viral_comments, viral_company_page_clicks, viral_external_website_conversions, viral_external_website_post_click_conversions, viral_external_website_post_view_conversions, viral_follows ...
    -- ^video_.*completions$: video_completions, video_first_quartile_completions, video_midpoint_completions, video_third_quartile_completions
    -- ^external_website_.*conversions$: external_website_conversions, external_website_post_click_conversions, external_website_post_view_conversions
    SELECT 
        "action_clicks",
        "ad_unit_clicks",
        "approximate_unique_impressions",
        "campaign_id",
        "card_clicks",
        "card_impressions",
        "clicks",
        "comment_likes",
        "comments",
        "company_page_clicks",
        "conversion_value_in_local_currency",
        "cost_in_local_currency",
        "cost_in_usd",
        "day_",
        "follows",
        "full_screen_plays",
        "impressions",
        "landing_page_clicks",
        "lead_generation_mail_contact_info_shares",
        "lead_generation_mail_interested_clicks",
        "likes",
        "one_click_lead_form_opens",
        "one_click_leads",
        "opens",
        "other_engagements",
        "shares",
        "text_url_clicks",
        "total_engagements",
        "video_starts",
        "video_views"
    FROM "linkedin_ad_analytics_by_campaign_data"
),

"linkedin_ad_analytics_by_campaign_data_removeWideColumns_renamed" AS (
    -- Rename: Renaming columns
    -- action_clicks -> action_button_clicks
    -- approximate_unique_impressions -> unique_impressions
    -- clicks -> total_clicks
    -- conversion_value_in_local_currency -> conversion_value_local
    -- cost_in_local_currency -> cost_local
    -- cost_in_usd -> cost_usd
    -- day_ -> date_
    -- impressions -> total_impressions
    -- lead_generation_mail_contact_info_shares -> lead_gen_mail_shares
    -- lead_generation_mail_interested_clicks -> lead_gen_mail_clicks
    -- one_click_lead_form_opens -> one_click_form_opens
    -- opens -> ad_opens
    SELECT 
        "action_clicks" AS "action_button_clicks",
        "ad_unit_clicks",
        "approximate_unique_impressions" AS "unique_impressions",
        "campaign_id",
        "card_clicks",
        "card_impressions",
        "clicks" AS "total_clicks",
        "comment_likes",
        "comments",
        "company_page_clicks",
        "conversion_value_in_local_currency" AS "conversion_value_local",
        "cost_in_local_currency" AS "cost_local",
        "cost_in_usd" AS "cost_usd",
        "day_" AS "date_",
        "follows",
        "full_screen_plays",
        "impressions" AS "total_impressions",
        "landing_page_clicks",
        "lead_generation_mail_contact_info_shares" AS "lead_gen_mail_shares",
        "lead_generation_mail_interested_clicks" AS "lead_gen_mail_clicks",
        "likes",
        "one_click_lead_form_opens" AS "one_click_form_opens",
        "one_click_leads",
        "opens" AS "ad_opens",
        "other_engagements",
        "shares",
        "text_url_clicks",
        "total_engagements",
        "video_starts",
        "video_views"
    FROM "linkedin_ad_analytics_by_campaign_data_removeWideColumns"
),

"linkedin_ad_analytics_by_campaign_data_removeWideColumns_renamed_casted" AS (
    -- Column Type Casting: 
    -- ad_unit_clicks: from DECIMAL to VARCHAR
    -- card_clicks: from DECIMAL to VARCHAR
    -- comments: from DECIMAL to VARCHAR
    -- company_page_clicks: from DECIMAL to VARCHAR
    -- date_: from VARCHAR to TIMESTAMP
    -- follows: from DECIMAL to VARCHAR
    -- full_screen_plays: from DECIMAL to VARCHAR
    -- likes: from DECIMAL to VARCHAR
    -- one_click_leads: from DECIMAL to VARCHAR
    -- text_url_clicks: from DECIMAL to VARCHAR
    -- video_starts: from DECIMAL to VARCHAR
    SELECT
        "action_button_clicks",
        "unique_impressions",
        "campaign_id",
        "card_impressions",
        "total_clicks",
        "comment_likes",
        "conversion_value_local",
        "cost_local",
        "cost_usd",
        "total_impressions",
        "landing_page_clicks",
        "lead_gen_mail_shares",
        "lead_gen_mail_clicks",
        "one_click_form_opens",
        "ad_opens",
        "other_engagements",
        "shares",
        "total_engagements",
        "video_views",
        CAST("ad_unit_clicks" AS VARCHAR) AS "ad_unit_clicks",
        CAST("card_clicks" AS VARCHAR) AS "card_clicks",
        CAST("comments" AS VARCHAR) AS "comments",
        CAST("company_page_clicks" AS VARCHAR) AS "company_page_clicks",
        CAST("date_" AS TIMESTAMP) AS "date_",
        CAST("follows" AS VARCHAR) AS "follows",
        CAST("full_screen_plays" AS VARCHAR) AS "full_screen_plays",
        CAST("likes" AS VARCHAR) AS "likes",
        CAST("one_click_leads" AS VARCHAR) AS "one_click_leads",
        CAST("text_url_clicks" AS VARCHAR) AS "text_url_clicks",
        CAST("video_starts" AS VARCHAR) AS "video_starts"
    FROM "linkedin_ad_analytics_by_campaign_data_removeWideColumns_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_ad_analytics_by_campaign_data_removeWideColumns_renamed_casted"

stg_linkedin_ad_analytics_by_campaign_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_ad_analytics_by_campaign_data
  description: The table is about LinkedIn ad campaign analytics. It contains daily
    metrics for a specific campaign (ID 148633856). Metrics include impressions, clicks,
    engagements, costs, and various interaction types (e.g., likes, comments, follows).
    The data spans multiple days in March and April 2020. It provides detailed insights
    into the campaign's performance across different engagement metrics and cost figures.
  columns:
  - name: action_button_clicks
    description: Number of clicks on action buttons
    cocoon_meta:
      missing_acceptable: No action buttons present in the ad
  - name: unique_impressions
    description: Estimated number of unique ad views
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the ad campaign
    tests:
    - not_null
  - name: card_impressions
    description: Number of times card ads were displayed
    tests:
    - not_null
  - name: total_clicks
    description: Total number of clicks on the ad
    tests:
    - not_null
  - name: comment_likes
    description: Number of likes on comments
    tests:
    - not_null
  - name: conversion_value_local
    description: Value of conversions in local currency
    tests:
    - not_null
  - name: cost_local
    description: Campaign cost in local currency
    tests:
    - not_null
  - name: cost_usd
    description: Campaign cost in US dollars
    tests:
    - not_null
  - name: total_impressions
    description: Total number of times ad was displayed
    tests:
    - not_null
  - name: landing_page_clicks
    description: Clicks on the ad's landing page
    cocoon_meta:
      missing_acceptable: No landing page linked to this ad
  - name: lead_gen_mail_shares
    description: Leads sharing contact info via mail
    tests:
    - not_null
  - name: lead_gen_mail_clicks
    description: Clicks on 'Interested' in lead gen emails
    tests:
    - not_null
  - name: one_click_form_opens
    description: Number of one-click lead form opens
    cocoon_meta:
      missing_acceptable: No one-click form used in this ad
  - name: ad_opens
    description: Number of ad opens or expansions
    tests:
    - not_null
  - name: other_engagements
    description: Count of miscellaneous engagements
    tests:
    - not_null
  - name: shares
    description: Number of times the ad was shared
    cocoon_meta:
      missing_acceptable: Share action not available for this ad type
  - name: total_engagements
    description: Sum of all engagement types
    tests:
    - not_null
  - name: video_views
    description: Number of video ad views
    tests:
    - not_null
  - name: ad_unit_clicks
    description: Number of clicks on ad units
    cocoon_meta:
      missing_acceptable: No ad units used in this campaign
  - name: card_clicks
    description: Number of clicks on LinkedIn card ads
    cocoon_meta:
      missing_acceptable: No cards used in this ad format
  - name: comments
    description: Number of comments on the ad
    cocoon_meta:
      missing_acceptable: Comments not enabled or allowed for this ad
  - name: company_page_clicks
    description: Clicks on the company's LinkedIn page
    cocoon_meta:
      missing_acceptable: No company page linked to this ad
  - name: date_
    description: Date of the reported metrics
    tests:
    - not_null
  - name: follows
    description: Number of new followers gained
    cocoon_meta:
      missing_acceptable: Follow action not available for this ad type
  - name: full_screen_plays
    description: Number of full-screen video plays
    cocoon_meta:
      missing_acceptable: No full-screen video content in this ad
  - name: likes
    description: Number of likes on the ad
    cocoon_meta:
      missing_acceptable: Like action not available for this ad type
  - name: one_click_leads
    description: Number of leads generated via one-click
    cocoon_meta:
      missing_acceptable: No one-click lead generation feature in this ad
  - name: text_url_clicks
    description: Clicks on text URLs within the ad
    cocoon_meta:
      missing_acceptable: No clickable text URLs in this ad
  - name: video_starts
    description: Number of video ad play starts
    cocoon_meta:
      missing_acceptable: No video content in this ad

stg_linkedin_account_history_data (first 100 rows)

account_id encrypted_account_name account_currency revision_number account_creation_time last_update_time
0 507515057 p6zp17DVJVjAD3VAr1btVw== USD 55 2017-06-07 22:44:32 2020-10-12 19:05:20.398
1 507515057 p6zp17DVJVjAD3VAr1btVw== USD 56 2017-06-07 22:44:32 2020-10-19 10:50:13.021
2 507515057 p6zp17DVJVjAD3VAr1btVw== USD 50 2017-06-07 22:44:32 2020-10-12 10:50:12.579
3 507515057 p6zp17DVJVjAD3VAr1btVw== USD 49 2017-06-07 22:44:32 2020-09-22 13:26:56.231
4 507515057 p6zp17DVJVjAD3VAr1btVw== USD 45 2017-06-07 22:44:32 2020-08-24 12:22:01.025
5 507515057 p6zp17DVJVjAD3VAr1btVw== USD 41 2017-06-07 22:44:32 2020-08-14 02:32:45.713
6 507515057 p6zp17DVJVjAD3VAr1btVw== USD 57 2017-06-07 22:44:32 2020-10-23 15:09:38.215
7 507515057 p6zp17DVJVjAD3VAr1btVw== USD 58 2017-06-07 22:44:32 2020-10-29 11:40:16.413
8 507515057 p6zp17DVJVjAD3VAr1btVw== USD 48 2017-06-07 22:44:32 2020-09-20 10:50:04.290
9 507515057 p6zp17DVJVjAD3VAr1btVw== USD 43 2017-06-07 22:44:32 2020-08-19 11:25:28.265
10 507515057 p6zp17DVJVjAD3VAr1btVw== USD 40 2017-06-07 22:44:32 2020-06-26 15:43:20.472
11 507515057 p6zp17DVJVjAD3VAr1btVw== USD 46 2017-06-07 22:44:32 2020-08-31 10:50:11.537
12 507515057 p6zp17DVJVjAD3VAr1btVw== USD 44 2017-06-07 22:44:32 2020-08-22 10:50:20.513
13 507515057 p6zp17DVJVjAD3VAr1btVw== USD 47 2017-06-07 22:44:32 2020-09-01 16:58:29.443

stg_linkedin_account_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_account_history_data_renamed" AS (
    -- Rename: Renaming columns
    -- id -> account_id
    -- last_modified_time -> last_update_time
    -- created_time -> account_creation_time
    -- name -> encrypted_account_name
    -- currency -> account_currency
    -- version_tag -> revision_number
    SELECT 
        "id" AS "account_id",
        "last_modified_time" AS "last_update_time",
        "created_time" AS "account_creation_time",
        "name" AS "encrypted_account_name",
        "currency" AS "account_currency",
        "version_tag" AS "revision_number"
    FROM "linkedin_account_history_data"
),

"linkedin_account_history_data_renamed_casted" AS (
    -- Column Type Casting: 
    -- account_creation_time: from VARCHAR to TIMESTAMP
    -- last_update_time: from VARCHAR to TIMESTAMP
    SELECT
        "account_id",
        "encrypted_account_name",
        "account_currency",
        "revision_number",
        CAST("account_creation_time" AS TIMESTAMP) AS "account_creation_time",
        CAST("last_update_time" AS TIMESTAMP) AS "last_update_time"
    FROM "linkedin_account_history_data_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_account_history_data_renamed_casted"

stg_linkedin_account_history_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_account_history_data
  description: The table is about LinkedIn account history. It tracks changes to a
    specific account over time. Each row represents a snapshot of the account at a
    particular moment. The table includes the account ID, modification time, creation
    time, encrypted name, currency, and a version tag. The version tag increases with
    each update, indicating the account's revision history.
  columns:
  - name: account_id
    description: Unique identifier for the LinkedIn account
    tests:
    - not_null
  - name: encrypted_account_name
    description: Encrypted name of the account holder
    tests:
    - not_null
  - name: account_currency
    description: Currency associated with the account
    tests:
    - not_null
  - name: revision_number
    description: Incremental number indicating account revision history
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the version number of the account, incrementing
        with each update. For this table, each row is a snapshot of the account at
        a different point in time. The revision_number is unique across rows as it
        increases with each update, making it a good identifier for each specific
        version of the account.
  - name: account_creation_time
    description: Timestamp when the account was initially created
    tests:
    - not_null
  - name: last_update_time
    description: Timestamp of the most recent account modification
    tests:
    - not_null

stg_linkedin_campaign_group_history_data (first 100 rows)

encrypted_group_name account_id campaign_group_id creation_timestamp last_modified_timestamp
0 f7l0OENVPPPqyXqP9TMSCw== 507515057 602751036 2018-09-06 16:31:50 2018-09-06 16:52:33
1 9eWX62RMpoodTvMVlpsIQw== 507515057 602018326 2018-05-18 00:49:23 2020-06-05 19:05:08
2 9eWX62RMpoodTvMVlpsIQw== 507515057 602018326 2018-05-18 00:49:23 2020-09-10 18:09:39
3 wpZy9D1VMXKii8s1G/8Umw== 507515057 600268686 2017-06-07 22:44:32 2017-06-07 22:44:32

stg_linkedin_campaign_group_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_campaign_group_history_data_renamed" AS (
    -- Rename: Renaming columns
    -- id -> campaign_group_id
    -- last_modified_time -> last_modified_timestamp
    -- created_time -> creation_timestamp
    -- name -> encrypted_group_name
    SELECT 
        "id" AS "campaign_group_id",
        "last_modified_time" AS "last_modified_timestamp",
        "account_id",
        "created_time" AS "creation_timestamp",
        "name" AS "encrypted_group_name"
    FROM "linkedin_campaign_group_history_data"
),

"linkedin_campaign_group_history_data_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- last_modified_timestamp: The problem is that one timestamp '2018-09-06 16:52:33.720' includes millisecond precision, while the others do not. The correct values should all follow the same format without milliseconds for consistency. The most frequent format is 'YYYY-MM-DD HH:MM:SS', so we'll map the unusual value to this format. 
    SELECT
        "campaign_group_id",
        CASE
            WHEN "last_modified_timestamp" = '2018-09-06 16:52:33.720' THEN '2018-09-06 16:52:33'
            ELSE "last_modified_timestamp"
        END AS "last_modified_timestamp",
        "account_id",
        "creation_timestamp",
        "encrypted_group_name"
    FROM "linkedin_campaign_group_history_data_renamed"
),

"linkedin_campaign_group_history_data_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- account_id: from INT to VARCHAR
    -- campaign_group_id: from INT to VARCHAR
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- last_modified_timestamp: from VARCHAR to TIMESTAMP
    SELECT
        "encrypted_group_name",
        CAST("account_id" AS VARCHAR) AS "account_id",
        CAST("campaign_group_id" AS VARCHAR) AS "campaign_group_id",
        CAST("creation_timestamp" AS TIMESTAMP) AS "creation_timestamp",
        CAST("last_modified_timestamp" AS TIMESTAMP) AS "last_modified_timestamp"
    FROM "linkedin_campaign_group_history_data_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_campaign_group_history_data_renamed_cleaned_casted"

stg_linkedin_campaign_group_history_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_campaign_group_history_data
  description: The table is about LinkedIn campaign groups. It contains historical
    data for each group, including unique ID, modification time, account ID, creation
    time, and encrypted name. Multiple rows can exist for the same group ID, representing
    changes over time. This allows tracking of how campaign groups evolve.
  columns:
  - name: encrypted_group_name
    description: Encrypted name of the campaign group
    tests:
    - not_null
  - name: account_id
    description: LinkedIn account identifier
    tests:
    - not_null
  - name: campaign_group_id
    description: Unique identifier for the campaign group
    tests:
    - not_null
  - name: creation_timestamp
    description: Timestamp of campaign group creation
    tests:
    - not_null
  - name: last_modified_timestamp
    description: Timestamp of last modification to the group
    tests:
    - not_null

stg_linkedin_ad_analytics_by_creative_data (first 100 rows)

local_currency_cost usd_cost creative_id date_ impression_count
0 0.0 NaN 112590914 2020-10-17 NaN
1 0.0 NaN 95761876 2020-10-09 NaN
2 0.0 NaN 102318493 2020-11-05 NaN
3 0.0 NaN 95761676 2020-10-10 NaN
4 0.0 NaN 104230363 2020-10-23 NaN
5 0.0 NaN 112600554 2020-10-20 NaN
6 0.0 NaN 95763356 2020-10-19 NaN
7 NaN 0.0 70668606 2019-08-02 113.0
8 NaN 0.0 69776656 2019-07-14 15.0
9 NaN 0.0 70668676 2019-08-27 217.0
10 NaN 0.0 44900346 2018-05-30 249.0
11 NaN 0.0 81968486 2020-03-18 65.0
12 NaN 0.0 70668676 2019-08-02 221.0
13 NaN 0.0 81968486 2020-03-13 41.0
14 NaN 0.0 82056746 2020-03-16 9.0
15 NaN 0.0 44900356 2018-06-15 317.0
16 NaN 0.0 70669876 2019-08-15 109.0
17 NaN 0.0 84578906 2020-05-06 136.0
18 NaN 0.0 80494806 2020-02-22 207.0
19 NaN 0.0 84909276 2020-05-05 8.0
20 NaN 0.0 76339806 2019-12-29 186.0
21 NaN 0.0 82056546 2020-04-01 425.0
22 NaN 0.0 44901886 2018-06-01 17.0
23 NaN 0.0 70668856 2019-07-31 144.0
24 NaN 0.0 84594916 2020-05-07 51.0
25 NaN 0.0 70668676 2019-09-04 31.0
26 NaN 0.0 44900366 2017-07-25 439.0
27 NaN 0.0 80494706 2020-02-21 1.0
28 NaN 0.0 44901876 2017-07-17 121.0
29 NaN 0.0 81968566 2020-03-21 54.0
30 NaN 0.0 44900356 2017-06-11 311.0
31 NaN 0.0 84897806 2020-05-21 329.0
32 NaN 0.0 70669876 2019-08-22 20.0
33 NaN 0.0 44900336 2018-07-28 181.0
34 NaN 0.0 44900356 2017-07-25 391.0
35 0.0 NaN 102326993 2020-08-12 NaN
36 0.0 NaN 111449024 2020-10-06 NaN
37 0.0 NaN 109754844 2020-09-16 NaN
38 0.0 NaN 111024974 2020-09-28 NaN
39 0.0 NaN 103117663 2020-08-06 NaN
40 0.0 NaN 107328744 2020-10-24 NaN
41 0.0 NaN 95763826 2020-10-16 NaN
42 0.0 NaN 94954376 2020-10-17 NaN
43 0.0 NaN 95762316 2020-10-11 NaN
44 NaN 0.0 44900366 2018-07-04 850.0
45 NaN 0.0 83878136 2020-04-20 22.0
46 NaN 0.0 70668606 2019-08-18 5.0
47 NaN 0.0 44900336 2018-05-27 309.0
48 NaN 0.0 84092676 2020-04-29 8.0
49 NaN 0.0 70668856 2019-08-29 9.0
50 NaN 0.0 70668306 2019-08-04 61.0
51 NaN 0.0 69775486 2019-07-24 1075.0
52 NaN 0.0 69776656 2019-08-22 84.0
53 NaN 0.0 48046336 2017-10-19 12.0
54 NaN 0.0 55220314 2018-06-04 54.0
55 NaN 0.0 44900356 2018-06-04 407.0
56 NaN 0.0 82056656 2020-03-16 14.0
57 NaN 0.0 44900356 2018-05-29 481.0
58 NaN 0.0 44901856 2018-05-13 109.0
59 NaN 0.0 70668676 2019-08-29 90.0
60 NaN 0.0 48046326 2018-08-11 29.0
61 NaN 0.0 70668606 2019-08-25 10.0
62 NaN 0.0 70669236 2019-08-11 20.0
63 NaN 0.0 81968586 2020-04-16 142.0
64 NaN 0.0 55220334 2018-06-11 721.0
65 NaN 0.0 70669876 2019-08-18 4.0
66 NaN 0.0 48046336 2017-10-22 2.0
67 NaN 0.0 44901866 2018-06-13 102.0
68 NaN 0.0 55220314 2018-05-28 111.0
69 NaN 0.0 70668606 2019-08-30 21.0
70 NaN 0.0 69776656 2019-08-02 90.0
71 NaN 0.0 44901866 2018-06-20 72.0
72 NaN 0.0 48046336 2018-07-13 2.0
73 NaN 0.0 76339806 2019-11-21 638.0
74 0.0 NaN 107427114 2020-09-17 NaN
75 0.0 NaN 107780874 2020-08-03 NaN
76 0.0 NaN 103860724 2020-07-22 NaN
77 0.0 NaN 94336026 2020-09-21 NaN
78 0.0 NaN 109331754 2020-09-01 NaN
79 0.0 NaN 107328014 2020-09-02 NaN
80 0.0 NaN 107426034 2020-07-24 NaN
81 0.0 NaN 107426034 2020-09-11 NaN
82 0.0 NaN 104229493 2020-10-21 NaN
83 0.0 NaN 104230513 2020-10-27 NaN
84 0.0 NaN 109947744 2020-10-21 NaN
85 0.0 NaN 104229703 2020-10-28 NaN
86 0.0 NaN 112487464 2020-10-08 NaN
87 NaN 0.0 70669876 2019-08-04 20.0
88 NaN 0.0 44901856 2018-06-05 267.0
89 NaN 0.0 44901886 2018-05-20 848.0
90 NaN 0.0 80494736 2020-02-25 9.0
91 NaN 0.0 44901866 2018-05-12 90.0
92 NaN 0.0 44901856 2018-05-27 175.0
93 NaN 0.0 81708396 2020-03-09 58.0
94 NaN 0.0 60400066 2018-11-24 73.0
95 NaN 0.0 44901866 2017-07-04 1424.0
96 NaN 0.0 44900346 2018-06-07 224.0
97 NaN 0.0 70669196 2019-08-24 3.0
98 NaN 0.0 55220314 2018-05-27 111.0
99 NaN 0.0 48046336 2018-07-09 1.0

stg_linkedin_ad_analytics_by_creative_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_ad_analytics_by_creative_data_renamed" AS (
    -- Rename: Renaming columns
    -- day_ -> date_
    -- clicks -> click_count
    -- impressions -> impression_count
    -- cost_in_local_currency -> local_currency_cost
    -- cost_in_usd -> usd_cost
    SELECT 
        "creative_id",
        "day_" AS "date_",
        "clicks" AS "click_count",
        "impressions" AS "impression_count",
        "cost_in_local_currency" AS "local_currency_cost",
        "cost_in_usd" AS "usd_cost"
    FROM "linkedin_ad_analytics_by_creative_data"
),

"linkedin_ad_analytics_by_creative_data_renamed_casted" AS (
    -- Column Type Casting: 
    -- click_count: from DECIMAL to INT
    -- creative_id: from INT to VARCHAR
    -- date_: from VARCHAR to TIMESTAMP
    -- impression_count: from DECIMAL to INT
    SELECT
        "local_currency_cost",
        "usd_cost",
        CAST("click_count" AS INT) AS "click_count",
        CAST("creative_id" AS VARCHAR) AS "creative_id",
        CAST("date_" AS TIMESTAMP) AS "date_",
        CAST("impression_count" AS INT) AS "impression_count"
    FROM "linkedin_ad_analytics_by_creative_data_renamed"
),

"linkedin_ad_analytics_by_creative_data_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 3 columns with unacceptable missing values
    -- click_count has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- impression_count has 29.0 percent missing. Strategy: 🔄 Unchanged
    -- usd_cost has 29.0 percent missing. Strategy: 🔄 Unchanged
    SELECT
        "local_currency_cost",
        "usd_cost",
        "creative_id",
        "date_",
        "impression_count"
    FROM "linkedin_ad_analytics_by_creative_data_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_ad_analytics_by_creative_data_renamed_casted_missing_handled"

stg_linkedin_ad_analytics_by_creative_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_ad_analytics_by_creative_data
  description: The table is about LinkedIn ad performance metrics. It contains data
    for individual ad creatives, tracked daily. The details include the creative ID,
    date, clicks, impressions, cost in local currency, and cost in USD. However, many
    fields appear to be empty in the sample data, with only creative ID, date, and
    local currency cost populated.
  columns:
  - name: local_currency_cost
    description: Cost of the ad in the local currency
    cocoon_meta:
      missing_acceptable: Zero cost implies no local currency cost applicable.
  - name: usd_cost
    description: Cost of the ad in US dollars
    tests:
    - not_null
  - name: creative_id
    description: Unique identifier for the ad creative
    tests:
    - not_null
  - name: date_
    description: Date of the ad performance data
    tests:
    - not_null
  - name: impression_count
    description: Number of times the ad was displayed
    tests:
    - not_null

stg_linkedin_campaign_history_data (first 100 rows)

encrypted_campaign_name campaign_version account_id campaign_group_id campaign_id creation_timestamp last_updated_timestamp
0 CY9rzUYh03PK3k6DJie09g== 33 507515057 600268686 132822896 2018-07-25 14:59:12 2019-09-14 17:53:17.393
1 A16SHlVkEdYzDYcuKAyKdQ== 34 507515057 600268686 132822186 2018-07-25 14:34:44 2019-09-14 17:53:19.538
2 lRq7HdKfzTQkOokgrw809Q== 33 507515057 600268686 132866546 2018-07-27 20:51:22 2019-09-14 17:52:40.697
3 vqkXsHSguUTB/tNx2xICkQ== 73 507515057 600268686 147624636 2020-02-17 08:55:44 2020-03-31 23:49:40.206
4 p878CnpgR+9mdq58o3nkhg== 64 507515057 600268686 147624646 2020-02-17 08:56:24 2020-03-31 23:49:40.206
5 kUcfickNRhqYy57PLNwqTQ== 66 507515057 600268686 148633856 2020-02-17 08:57:41 2020-03-31 23:49:40.206
6 +A+12nfTw2I6vA3PNV0GDw== 125 507515057 600268686 148633856 2020-05-06 20:41:33 2020-07-14 11:54:05.000
7 +A+12nfTw2I6vA3PNV0GDw== 170 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-19 08:00:30.000
8 +A+12nfTw2I6vA3PNV0GDw== 171 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-19 15:20:48.000
9 +A+12nfTw2I6vA3PNV0GDw== 167 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-18 10:07:35.000
10 +A+12nfTw2I6vA3PNV0GDw== 163 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-16 16:44:41.000
11 +A+12nfTw2I6vA3PNV0GDw== 166 507515057 600268686 174096954 2020-05-06 20:41:33 2020-10-17 23:08:54.000
12 +A+12nfTw2I6vA3PNV0GDw== 164 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-17 02:47:20.000
13 +A+12nfTw2I6vA3PNV0GDw== 160 507515057 600268686 162286513 2020-05-06 20:41:33 2020-08-07 09:26:07.000
14 +A+12nfTw2I6vA3PNV0GDw== 175 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-22 21:56:41.000
15 +A+12nfTw2I6vA3PNV0GDw== 145 507515057 600268686 162286513 2020-05-06 20:41:33 2020-08-06 21:10:53.000
16 +A+12nfTw2I6vA3PNV0GDw== 141 507515057 600268686 167276694 2020-05-06 20:41:33 2020-07-21 00:57:53.000
17 +A+12nfTw2I6vA3PNV0GDw== 124 507515057 600268686 162286513 2020-05-06 20:41:33 2020-07-13 20:22:54.000
18 +A+12nfTw2I6vA3PNV0GDw== 144 507515057 600268686 162286513 2020-05-06 20:41:33 2020-08-06 17:12:01.000
19 +A+12nfTw2I6vA3PNV0GDw== 162 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-16 07:40:36.000
20 +A+12nfTw2I6vA3PNV0GDw== 165 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-17 11:38:02.000
21 +A+12nfTw2I6vA3PNV0GDw== 161 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-15 16:48:15.000
22 +A+12nfTw2I6vA3PNV0GDw== 168 507515057 600268686 162286513 2020-05-06 20:41:33 2020-10-18 20:13:44.000
23 XjFwQcqOj/a3ca8uS3EUzA== 126 507515057 600268686 165867684 2020-05-06 20:37:36 2020-07-13 19:55:36.000
24 XjFwQcqOj/a3ca8uS3EUzA== 206 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-24 21:06:55.000
25 XjFwQcqOj/a3ca8uS3EUzA== 226 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-16 16:20:40.000
26 XjFwQcqOj/a3ca8uS3EUzA== 227 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-17 04:59:30.000
27 XjFwQcqOj/a3ca8uS3EUzA== 225 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-16 06:25:34.000
28 XjFwQcqOj/a3ca8uS3EUzA== 152 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-26 16:24:19.000
29 XjFwQcqOj/a3ca8uS3EUzA== 127 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-14 11:27:20.000
30 XjFwQcqOj/a3ca8uS3EUzA== 202 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-23 01:18:19.000
31 XjFwQcqOj/a3ca8uS3EUzA== 223 507515057 600268686 162286313 2020-05-06 20:37:36 2020-09-11 00:16:38.000
32 XjFwQcqOj/a3ca8uS3EUzA== 151 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-26 00:53:40.000
33 XjFwQcqOj/a3ca8uS3EUzA== 153 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-27 09:37:28.000
34 XjFwQcqOj/a3ca8uS3EUzA== 148 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-24 05:58:28.000
35 XjFwQcqOj/a3ca8uS3EUzA== 213 507515057 600268686 162286313 2020-05-06 20:37:36 2020-09-09 16:16:40.000
36 XjFwQcqOj/a3ca8uS3EUzA== 159 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-30 20:32:59.000
37 XjFwQcqOj/a3ca8uS3EUzA== 224 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-15 16:48:11.000
38 XjFwQcqOj/a3ca8uS3EUzA== 237 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-22 21:55:05.000
39 XjFwQcqOj/a3ca8uS3EUzA== 198 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-20 21:50:50.000
40 XjFwQcqOj/a3ca8uS3EUzA== 154 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-28 01:22:33.000
41 XjFwQcqOj/a3ca8uS3EUzA== 158 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-30 09:34:24.000
42 XjFwQcqOj/a3ca8uS3EUzA== 149 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-24 18:36:37.000
43 XjFwQcqOj/a3ca8uS3EUzA== 156 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-29 01:32:28.000
44 XjFwQcqOj/a3ca8uS3EUzA== 150 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-25 11:39:44.000
45 XjFwQcqOj/a3ca8uS3EUzA== 231 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-18 19:52:27.000
46 XjFwQcqOj/a3ca8uS3EUzA== 145 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-22 10:11:24.000
47 XjFwQcqOj/a3ca8uS3EUzA== 195 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-19 03:16:42.000
48 XjFwQcqOj/a3ca8uS3EUzA== 197 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-20 07:35:29.000
49 XjFwQcqOj/a3ca8uS3EUzA== 144 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-21 18:43:55.000
50 XjFwQcqOj/a3ca8uS3EUzA== 155 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-28 13:19:59.000
51 XjFwQcqOj/a3ca8uS3EUzA== 203 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-23 15:07:52.000
52 XjFwQcqOj/a3ca8uS3EUzA== 160 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-31 12:30:00.000
53 XjFwQcqOj/a3ca8uS3EUzA== 146 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-23 03:17:43.000
54 XjFwQcqOj/a3ca8uS3EUzA== 196 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-19 16:10:52.000
55 XjFwQcqOj/a3ca8uS3EUzA== 229 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-17 22:05:52.000
56 XjFwQcqOj/a3ca8uS3EUzA== 233 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-19 08:49:28.000
57 XjFwQcqOj/a3ca8uS3EUzA== 234 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-19 15:20:42.000
58 XjFwQcqOj/a3ca8uS3EUzA== 208 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-25 03:59:10.000
59 XjFwQcqOj/a3ca8uS3EUzA== 210 507515057 600268686 162286313 2020-05-06 20:37:36 2020-09-01 16:54:53.000
60 XjFwQcqOj/a3ca8uS3EUzA== 157 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-29 14:42:05.000
61 XjFwQcqOj/a3ca8uS3EUzA== 199 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-21 15:48:02.000
62 XjFwQcqOj/a3ca8uS3EUzA== 228 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-17 12:21:20.000
63 XjFwQcqOj/a3ca8uS3EUzA== 205 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-24 10:25:27.000
64 XjFwQcqOj/a3ca8uS3EUzA== 147 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-23 16:12:35.000
65 XjFwQcqOj/a3ca8uS3EUzA== 211 507515057 600268686 162286313 2020-05-06 20:37:36 2020-09-02 00:16:42.000
66 XjFwQcqOj/a3ca8uS3EUzA== 143 507515057 600268686 162286313 2020-05-06 20:37:36 2020-07-21 00:58:26.000
67 XjFwQcqOj/a3ca8uS3EUzA== 230 507515057 600268686 162286313 2020-05-06 20:37:36 2020-10-18 10:30:01.000
68 XjFwQcqOj/a3ca8uS3EUzA== 201 507515057 600268686 162286313 2020-05-06 20:37:36 2020-08-22 11:22:38.000
69 aKI/VAmh+UP8KcE2Q5bXRg== 102 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-25 17:32:04.000
70 aKI/VAmh+UP8KcE2Q5bXRg== 98 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-22 15:02:04.000
71 aKI/VAmh+UP8KcE2Q5bXRg== 109 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-30 17:26:32.000
72 aKI/VAmh+UP8KcE2Q5bXRg== 55 507515057 600268686 162288753 2020-05-06 21:23:28 2020-08-29 07:20:19.000
73 aKI/VAmh+UP8KcE2Q5bXRg== 89 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-18 02:11:54.000
74 aKI/VAmh+UP8KcE2Q5bXRg== 83 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-14 10:38:17.000
75 aKI/VAmh+UP8KcE2Q5bXRg== 114 507515057 600268686 162288753 2020-05-06 21:23:28 2020-10-04 04:07:29.000
76 aKI/VAmh+UP8KcE2Q5bXRg== 101 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-25 01:29:52.000
77 aKI/VAmh+UP8KcE2Q5bXRg== 104 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-27 09:07:13.000
78 aKI/VAmh+UP8KcE2Q5bXRg== 71 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-07 01:45:26.000
79 aKI/VAmh+UP8KcE2Q5bXRg== 105 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-28 04:39:20.000
80 aKI/VAmh+UP8KcE2Q5bXRg== 85 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-15 15:09:44.000
81 aKI/VAmh+UP8KcE2Q5bXRg== 90 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-18 17:05:50.000
82 aKI/VAmh+UP8KcE2Q5bXRg== 116 507515057 600268686 162288753 2020-05-06 21:23:28 2020-10-05 14:35:47.000
83 aKI/VAmh+UP8KcE2Q5bXRg== 115 507515057 600268686 162288753 2020-05-06 21:23:28 2020-10-04 23:47:19.000
84 aKI/VAmh+UP8KcE2Q5bXRg== 63 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-02 03:27:14.000
85 aKI/VAmh+UP8KcE2Q5bXRg== 69 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-05 19:12:44.000
86 aKI/VAmh+UP8KcE2Q5bXRg== 70 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-06 08:32:32.000
87 aKI/VAmh+UP8KcE2Q5bXRg== 60 507515057 600268686 162288753 2020-05-06 21:23:28 2020-08-31 17:27:01.000
88 aKI/VAmh+UP8KcE2Q5bXRg== 95 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-21 07:08:26.000
89 aKI/VAmh+UP8KcE2Q5bXRg== 112 507515057 600268686 162288753 2020-05-06 21:23:28 2020-10-02 19:42:11.000
90 aKI/VAmh+UP8KcE2Q5bXRg== 93 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-19 23:42:57.000
91 aKI/VAmh+UP8KcE2Q5bXRg== 99 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-23 07:32:14.000
92 aKI/VAmh+UP8KcE2Q5bXRg== 74 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-08 19:42:07.000
93 aKI/VAmh+UP8KcE2Q5bXRg== 97 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-22 01:24:42.000
94 aKI/VAmh+UP8KcE2Q5bXRg== 88 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-17 10:15:03.000
95 aKI/VAmh+UP8KcE2Q5bXRg== 81 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-13 02:47:37.000
96 aKI/VAmh+UP8KcE2Q5bXRg== 113 507515057 600268686 162288753 2020-05-06 21:23:28 2020-10-03 10:28:28.000
97 aKI/VAmh+UP8KcE2Q5bXRg== 94 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-20 15:31:37.000
98 aKI/VAmh+UP8KcE2Q5bXRg== 100 507515057 600268686 162288753 2020-05-06 21:23:28 2020-09-24 07:20:21.000
99 aKI/VAmh+UP8KcE2Q5bXRg== 54 507515057 600268686 162288753 2020-05-06 21:23:28 2020-08-28 14:56:39.000

stg_linkedin_campaign_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_campaign_history_data_renamed" AS (
    -- Rename: Renaming columns
    -- id -> campaign_id
    -- last_modified_time -> last_updated_timestamp
    -- created_time -> creation_timestamp
    -- name -> encrypted_campaign_name
    -- version_tag -> campaign_version
    SELECT 
        "id" AS "campaign_id",
        "last_modified_time" AS "last_updated_timestamp",
        "account_id",
        "campaign_group_id",
        "created_time" AS "creation_timestamp",
        "name" AS "encrypted_campaign_name",
        "version_tag" AS "campaign_version"
    FROM "linkedin_campaign_history_data"
),

"linkedin_campaign_history_data_renamed_casted" AS (
    -- Column Type Casting: 
    -- account_id: from INT to VARCHAR
    -- campaign_group_id: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- last_updated_timestamp: from VARCHAR to TIMESTAMP
    SELECT
        "encrypted_campaign_name",
        "campaign_version",
        CAST("account_id" AS VARCHAR) AS "account_id",
        CAST("campaign_group_id" AS VARCHAR) AS "campaign_group_id",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("creation_timestamp" AS TIMESTAMP) AS "creation_timestamp",
        CAST("last_updated_timestamp" AS TIMESTAMP) AS "last_updated_timestamp"
    FROM "linkedin_campaign_history_data_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_campaign_history_data_renamed_casted"

stg_linkedin_campaign_history_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_campaign_history_data
  description: The table is about LinkedIn campaign history data. It includes details
    such as campaign ID, modification time, account ID, campaign group ID, creation
    time, campaign name (encrypted), and version tag. Each row represents a unique
    campaign with its associated information. The table tracks changes and updates
    to LinkedIn advertising campaigns over time.
  columns:
  - name: encrypted_campaign_name
    description: Encrypted name of the campaign
    tests:
    - not_null
  - name: campaign_version
    description: Version number of the campaign
    tests:
    - not_null
  - name: account_id
    description: Unique identifier for the LinkedIn advertising account
    tests:
    - not_null
  - name: campaign_group_id
    description: ID of the campaign group the campaign belongs to
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the specific campaign
    tests:
    - not_null
  - name: creation_timestamp
    description: Timestamp when the campaign was initially created
    tests:
    - not_null
  - name: last_updated_timestamp
    description: Timestamp of the most recent modification to the campaign
    tests:
    - not_null

stg_linkedin_creative_history_data (first 100 rows)

creative_id campaign_id content_status click_through_url creation_timestamp last_modified_timestamp
0 112590914 131580446 CANCELED https://google.com 2018-05-24 00:38:47 2020-07-01 00:32:56
1 95761876 131454616 CANCELED None 2018-05-18 01:04:02 2020-07-01 00:32:56
2 102318493 167276694 ACTIVE None 2020-09-10 18:08:57 2020-09-10 18:29:16
3 95761676 165867684 ACTIVE None 2020-07-22 19:28:31 2020-07-27 15:19:33
4 104230363 165867684 DRAFT None 2020-07-22 19:28:31 2020-07-22 19:28:31
5 112600554 162464924 ACTIVE None 2020-05-08 09:34:15 2020-05-08 11:37:43
6 95763356 162557074 ACTIVE None 2020-05-12 14:08:40 2020-05-12 15:39:25
7 70668606 131454826 CANCELED None 2018-05-18 01:09:08 2020-07-01 00:32:56
8 69776656 148633856 ACTIVE None 2020-03-20 18:55:40 2020-03-23 14:52:29
9 70668676 131580546 CANCELED None 2018-05-24 00:47:40 2020-07-01 00:32:56
10 44900346 148711996 ACTIVE None 2020-03-24 17:56:49 2020-03-24 18:05:27
11 81968486 125600246 ACTIVE None 2017-06-08 21:46:06 2018-02-12 10:09:41
12 70668676 125600246 ACTIVE None 2017-06-08 21:46:06 2018-02-12 10:09:19
13 81968486 125600246 ACTIVE None 2017-06-08 21:46:06 2018-02-12 10:09:56
14 82056746 125600246 ACTIVE None 2017-06-08 21:46:06 2018-02-12 10:09:27
15 44900356 133160324 PAUSED None 2017-08-04 22:45:09 2020-07-23 17:22:59
16 70669876 133160324 ACTIVE None 2017-08-04 22:45:09 2018-05-11 12:38:59
17 84578906 125599426 ACTIVE None 2017-06-08 22:29:09 2018-02-12 10:22:30
18 80494806 125599426 ACTIVE None 2017-06-08 22:29:09 2018-02-12 10:22:34
19 84909276 133160324 ACTIVE None 2017-08-04 22:45:09 2018-05-11 12:38:59
20 76339806 125599426 ACTIVE None 2017-06-08 22:29:09 2018-02-12 10:22:39
21 82056546 133160324 ACTIVE None 2017-08-04 22:45:09 2018-05-11 12:38:59
22 44901886 133160324 ACTIVE None 2017-08-04 22:45:09 2018-05-11 12:38:59
23 70668856 125599426 ACTIVE None 2017-06-08 22:29:09 2018-02-12 10:22:43
24 84594916 127624356 PAUSED None 2017-10-10 16:49:38 2018-08-07 15:13:09
25 70668676 127624356 PAUSED None 2017-10-10 16:49:38 2018-08-31 20:21:58
26 44900366 127624356 PAUSED None 2017-10-10 16:49:38 2018-08-31 20:21:56
27 80494706 128806186 ACTIVE None 2017-12-22 17:38:12 2018-04-19 01:01:41
28 44901876 128806016 ACTIVE None 2017-12-22 17:27:45 2018-04-20 16:09:25
29 81968566 128806186 ACTIVE None 2017-12-22 17:38:12 2018-04-20 20:54:43
30 44900356 128806016 ACTIVE None 2017-12-22 17:27:45 2018-04-20 20:54:36
31 84897806 132822186 PAUSED None 2018-07-25 15:04:05 2018-07-28 18:42:52
32 70669876 132870856 ACTIVE None 2018-07-28 18:48:26 2018-07-28 18:57:01
33 44900336 132866546 ARCHIVED None 2018-07-28 18:38:10 2018-07-28 18:44:22
34 44900356 133672706 ACTIVE None 2018-09-06 16:59:15 2018-09-10 23:06:50
35 102326993 133728466 ACTIVE None 2018-09-10 17:52:28 2018-09-10 17:55:24
36 111449024 133736786 ACTIVE None 2018-09-10 23:16:13 2018-09-10 23:18:06
37 109754844 133822116 ACTIVE None 2018-09-13 17:59:19 2018-09-13 18:01:26
38 111024974 134383046 ACTIVE None 2018-10-08 17:49:29 2018-10-08 17:51:55
39 103117663 134383176 ACTIVE None 2018-10-08 17:54:17 2018-10-08 17:55:09
40 107328744 134988516 ACTIVE None 2018-10-31 17:30:40 2018-11-14 21:16:03
41 95763826 135583676 ACTIVE None 2018-11-21 17:08:53 2018-11-23 12:57:25
42 94954376 136022286 ACTIVE None 2018-12-10 18:01:42 2018-12-10 18:03:37
43 95762316 136508426 ACTIVE None 2019-01-08 17:27:32 2019-01-08 17:52:12
44 44900366 136509566 ACTIVE None 2019-01-08 17:57:44 2019-01-08 18:00:10
45 83878136 136598756 ACTIVE None 2019-01-11 21:00:57 2019-01-11 21:06:51
46 70668606 136746346 ACTIVE None 2019-01-17 19:19:05 2019-01-17 22:39:37
47 44900336 137527956 ACTIVE None 2019-02-20 17:23:30 2019-02-20 23:02:25
48 84092676 137559956 ACTIVE None 2019-02-21 17:46:17 2019-02-21 17:53:26
49 70668856 137824786 ACTIVE None 2019-03-04 19:12:56 2019-03-04 19:37:29
50 70668306 139304236 ACTIVE None 2019-04-29 17:20:56 2019-04-29 17:21:39
51 69775486 139304466 ACTIVE None 2019-04-29 17:32:14 2019-04-29 17:45:59
52 69776656 139548496 ACTIVE None 2019-05-08 17:34:16 2019-05-08 18:31:04
53 48046336 139581266 ACTIVE None 2019-05-09 15:19:05 2019-05-09 15:47:39
54 55220314 139619466 ACTIVE None 2019-05-10 16:05:30 2019-05-10 19:24:18
55 44900356 139812856 ACTIVE None 2019-05-17 14:50:20 2019-05-17 16:53:00
56 82056656 140203726 ACTIVE None 2019-06-03 19:34:54 2019-06-03 20:44:36
57 44900356 140206956 ACTIVE None 2019-06-03 20:59:46 2019-06-03 20:59:59
58 44901856 140506806 ACTIVE None 2019-06-14 17:17:18 2019-06-14 17:17:25
59 70668676 140715576 PAUSED None 2019-06-21 18:33:19 2019-07-01 20:07:24
60 48046326 141092076 ACTIVE None 2019-07-08 15:16:08 2019-07-08 15:39:00
61 70668606 141091746 ACTIVE None 2019-07-08 15:13:19 2019-07-29 15:16:22
62 70669236 141092526 ACTIVE None 2019-07-08 15:24:18 2019-07-08 15:24:28
63 81968586 141092656 ACTIVE None 2019-07-08 15:29:15 2019-07-08 15:29:26
64 55220334 141360566 ACTIVE None 2019-07-18 15:40:03 2019-07-18 15:40:35
65 70669876 141360566 ACTIVE None 2019-07-29 18:33:05 2019-07-29 18:33:07
66 48046336 141360566 ACTIVE None 2019-07-29 18:35:50 2019-07-29 18:36:00
67 44901866 141360566 ACTIVE None 2019-07-29 18:37:21 2019-07-29 18:45:38
68 55220314 141091746 ACTIVE None 2019-07-29 18:40:24 2019-09-02 12:50:44
69 70668606 141091746 ACTIVE None 2019-07-29 18:41:41 2019-07-29 18:41:56
70 69776656 141091746 ACTIVE None 2019-07-29 18:43:04 2019-07-29 18:43:33
71 44901866 141092526 ACTIVE None 2019-07-29 18:46:41 2019-07-29 18:46:44
72 48046336 141092526 ACTIVE None 2019-07-29 18:48:12 2019-07-29 18:48:14
73 76339806 141092526 ACTIVE None 2019-07-29 18:52:24 2019-07-29 18:52:40
74 107427114 141092656 ACTIVE None 2019-07-29 18:53:27 2019-07-29 18:53:31
75 107780874 141092656 ACTIVE None 2019-07-29 18:54:42 2019-07-29 18:55:06
76 103860724 141092656 ACTIVE None 2019-07-29 19:08:28 2019-07-29 19:08:42
77 94336026 142718926 ACTIVE None 2019-09-06 16:54:36 2019-09-06 17:06:44
78 109331754 142723626 ACTIVE None 2019-09-06 18:47:11 2019-09-07 01:31:08
79 107328014 142886156 ACTIVE None 2019-09-12 16:48:25 2019-09-12 16:49:10
80 107426034 144266096 ACTIVE None 2019-10-30 17:47:59 2019-10-30 17:48:33
81 107426034 144267636 ACTIVE None 2019-10-30 18:28:17 2019-10-30 18:28:54
82 104229493 144486446 ACTIVE None 2019-11-06 18:14:42 2019-11-06 18:15:13
83 104230513 144730056 ACTIVE None 2019-11-14 15:58:40 2019-11-14 15:59:08
84 109947744 146251416 ACTIVE None 2019-12-18 16:13:57 2019-12-18 17:06:17
85 104229703 146251626 ACTIVE None 2019-12-19 15:42:00 2019-12-19 16:59:51
86 112487464 146537336 ACTIVE None 2020-01-07 19:05:17 2020-01-07 19:05:55
87 70669876 147221246 ACTIVE None 2020-02-03 20:10:59 2020-02-03 20:11:30
88 44901856 148790486 ACTIVE None 2020-03-26 20:37:02 2020-03-26 20:37:26
89 44901886 148790536 ACTIVE None 2020-03-26 20:37:44 2020-03-26 20:38:13
90 80494736 148790586 ACTIVE None 2020-03-26 20:38:25 2020-03-26 20:38:58
91 44901866 149101206 ACTIVE None 2020-04-07 15:10:41 2020-04-07 15:12:31
92 44901856 149101696 ACTIVE None 2020-04-07 15:24:12 2020-04-07 18:49:47
93 81708396 149102126 ACTIVE None 2020-04-07 15:31:39 2020-04-07 15:32:09
94 60400066 149834446 PAUSED None 2020-04-28 15:27:36 2020-06-01 15:53:04
95 44901866 162905364 ACTIVE None 2020-05-26 11:09:20 2020-05-26 11:11:58
96 44900346 166816004 ACTIVE None 2020-08-21 21:14:46 2020-08-21 21:15:10
97 70669196 166816034 ACTIVE None 2020-08-21 21:15:23 2020-08-21 21:15:47
98 55220314 166816044 ACTIVE None 2020-08-21 21:15:59 2020-08-21 21:16:11
99 48046336 166816094 ACTIVE None 2020-08-21 21:17:13 2020-08-21 21:17:17

stg_linkedin_creative_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"linkedin_creative_history_data_renamed" AS (
    -- Rename: Renaming columns
    -- id -> creative_id
    -- last_modified_at -> last_modified_timestamp
    -- created_at -> creation_timestamp
    -- intended_status -> content_status
    -- click_uri -> click_through_url
    SELECT 
        "id" AS "creative_id",
        "last_modified_at" AS "last_modified_timestamp",
        "created_at" AS "creation_timestamp",
        "campaign_id",
        "intended_status" AS "content_status",
        "click_uri" AS "click_through_url"
    FROM "linkedin_creative_history_data"
),

"linkedin_creative_history_data_renamed_casted" AS (
    -- Column Type Casting: 
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- last_modified_timestamp: from VARCHAR to TIMESTAMP
    SELECT
        "creative_id",
        "campaign_id",
        "content_status",
        "click_through_url",
        CAST("creation_timestamp" AS TIMESTAMP) AS "creation_timestamp",
        CAST("last_modified_timestamp" AS TIMESTAMP) AS "last_modified_timestamp"
    FROM "linkedin_creative_history_data_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "linkedin_creative_history_data_renamed_casted"

stg_linkedin_creative_history_data.yml (Document the table)

version: 2
models:
- name: stg_linkedin_creative_history_data
  description: The table is about LinkedIn creative content history. It includes details
    like unique ID, modification and creation timestamps, associated campaign ID,
    status (e.g., ACTIVE, CANCELED, DRAFT), and click URI. Each row represents a specific
    creative content item used in LinkedIn advertising campaigns, tracking its lifecycle
    and current status.
  columns:
  - name: creative_id
    description: Unique identifier for the creative content item
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the associated advertising campaign
    tests:
    - not_null
  - name: content_status
    description: Current status of the creative content
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - PAUSED
        - CANCELED
        - ARCHIVED
        - DRAFT
  - name: click_through_url
    description: URL destination for ad clicks
    cocoon_meta:
      missing_acceptable: Not all campaigns require or have a click-through URL.
  - name: creation_timestamp
    description: Timestamp of when the creative content was created
    tests:
    - not_null
  - name: last_modified_timestamp
    description: Timestamp of the most recent modification
    tests:
    - not_null
Some tables log change events, which may be redundant to query. Instead, we take a snapshot of the latest.

snapshot_linkedin_creative_history_data (first 100 rows)

creative_id campaign_id content_status click_through_url creation_timestamp
0 84594916 127624356 PAUSED None 2017-10-10 16:49:38
1 104230513 144730056 ACTIVE None 2019-11-14 15:58:40
2 107427114 141092656 ACTIVE None 2019-07-29 18:53:27
3 70668606 131454826 CANCELED None 2018-05-18 01:09:08
4 70668676 131580546 CANCELED None 2018-05-24 00:47:40
5 112600554 162464924 ACTIVE None 2020-05-08 09:34:15
6 82056656 140203726 ACTIVE None 2019-06-03 19:34:54
7 84897806 132822186 PAUSED None 2018-07-25 15:04:05
8 44900336 137527956 ACTIVE None 2019-02-20 17:23:30
9 70668306 139304236 ACTIVE None 2019-04-29 17:20:56
10 76339806 141092526 ACTIVE None 2019-07-29 18:52:24
11 95763356 162557074 ACTIVE None 2020-05-12 14:08:40
12 102318493 167276694 ACTIVE None 2020-09-10 18:08:57
13 69776656 148633856 ACTIVE None 2020-03-20 18:55:40
14 82056746 125600246 ACTIVE None 2017-06-08 21:46:06
15 95762316 136508426 ACTIVE None 2019-01-08 17:27:32
16 104230363 165867684 DRAFT None 2020-07-22 19:28:31
17 109331754 142723626 ACTIVE None 2019-09-06 18:47:11
18 44900366 136509566 ACTIVE None 2019-01-08 17:57:44
19 44901876 128806016 ACTIVE None 2017-12-22 17:27:45
20 48046336 166816094 ACTIVE None 2020-08-21 21:17:13
21 60400066 149834446 PAUSED None 2020-04-28 15:27:36
22 81968566 128806186 ACTIVE None 2017-12-22 17:38:12
23 107426034 144267636 ACTIVE None 2019-10-30 18:28:17
24 69775486 139304466 ACTIVE None 2019-04-29 17:32:14
25 70669236 141092526 ACTIVE None 2019-07-08 15:24:18
26 81968586 141092656 ACTIVE None 2019-07-08 15:29:15
27 94336026 142718926 ACTIVE None 2019-09-06 16:54:36
28 95761876 131454616 CANCELED None 2018-05-18 01:04:02
29 95763826 135583676 ACTIVE None 2018-11-21 17:08:53
30 107780874 141092656 ACTIVE None 2019-07-29 18:54:42
31 44901886 148790536 ACTIVE None 2020-03-26 20:37:44
32 80494806 125599426 ACTIVE None 2017-06-08 22:29:09
33 81708396 149102126 ACTIVE None 2020-04-07 15:31:39
34 84909276 133160324 ACTIVE None 2017-08-04 22:45:09
35 112487464 146537336 ACTIVE None 2020-01-07 19:05:17
36 112590914 131580446 CANCELED https://google.com 2018-05-24 00:38:47
37 70669876 147221246 ACTIVE None 2020-02-03 20:10:59
38 80494706 128806186 ACTIVE None 2017-12-22 17:38:12
39 80494736 148790586 ACTIVE None 2020-03-26 20:38:25
40 84578906 125599426 ACTIVE None 2017-06-08 22:29:09
41 104229703 146251626 ACTIVE None 2019-12-19 15:42:00
42 55220314 166816044 ACTIVE None 2020-08-21 21:15:59
43 70669196 166816034 ACTIVE None 2020-08-21 21:15:23
44 82056546 133160324 ACTIVE None 2017-08-04 22:45:09
45 109947744 146251416 ACTIVE None 2019-12-18 16:13:57
46 111449024 133736786 ACTIVE None 2018-09-10 23:16:13
47 44900346 166816004 ACTIVE None 2020-08-21 21:14:46
48 84092676 137559956 ACTIVE None 2019-02-21 17:46:17
49 107328744 134988516 ACTIVE None 2018-10-31 17:30:40
50 103860724 141092656 ACTIVE None 2019-07-29 19:08:28
51 83878136 136598756 ACTIVE None 2019-01-11 21:00:57
52 95761676 165867684 ACTIVE None 2020-07-22 19:28:31
53 104229493 144486446 ACTIVE None 2019-11-06 18:14:42
54 109754844 133822116 ACTIVE None 2018-09-13 17:59:19
55 44901856 149101696 ACTIVE None 2020-04-07 15:24:12
56 44901866 162905364 ACTIVE None 2020-05-26 11:09:20
57 48046326 141092076 ACTIVE None 2019-07-08 15:16:08
58 81968486 125600246 ACTIVE None 2017-06-08 21:46:06
59 94954376 136022286 ACTIVE None 2018-12-10 18:01:42
60 107328014 142886156 ACTIVE None 2019-09-12 16:48:25
61 44900356 133160324 PAUSED None 2017-08-04 22:45:09
62 102326993 133728466 ACTIVE None 2018-09-10 17:52:28
63 55220334 141360566 ACTIVE None 2019-07-18 15:40:03
64 70668856 137824786 ACTIVE None 2019-03-04 19:12:56
65 103117663 134383176 ACTIVE None 2018-10-08 17:54:17
66 111024974 134383046 ACTIVE None 2018-10-08 17:49:29

snapshot_linkedin_creative_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "creative_id"
-- Effective date columns are "last_modified_timestamp"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "creative_id",
    "campaign_id",
    "content_status",
    "click_through_url",
    "creation_timestamp"
FROM (
     SELECT 
            "creative_id",
            "campaign_id",
            "content_status",
            "click_through_url",
            "creation_timestamp",
            ROW_NUMBER() OVER (
                PARTITION BY "creative_id" 
                ORDER BY "last_modified_timestamp" 
            DESC) AS "cocoon_rn"
    FROM "stg_linkedin_creative_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_linkedin_creative_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_linkedin_creative_history_data
  description: The table is about current LinkedIn creative content. It tracks the
    most recent version of each creative item used in advertising campaigns. The table
    includes unique creative IDs, associated campaign IDs, content status, click-through
    URLs, and creation timestamps. Each row represents the latest state of a specific
    creative content, providing a snapshot of active, canceled, or draft items.
  columns:
  - name: creative_id
    description: Unique identifier for the creative content item
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: campaign_id
    description: Unique identifier for the associated advertising campaign
    tests:
    - not_null
  - name: content_status
    description: Current status of the creative content
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - PAUSED
        - CANCELED
        - ARCHIVED
        - DRAFT
  - name: click_through_url
    description: URL destination for ad clicks
    cocoon_meta:
      missing_acceptable: Not all campaigns require or have a click-through URL.
  - name: creation_timestamp
    description: Timestamp of when the creative content was created
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_linkedin_creative_history_data

snapshot_linkedin_campaign_history_data (first 100 rows)

encrypted_campaign_name campaign_version account_id campaign_group_id campaign_id creation_timestamp
0 CY9rzUYh03PK3k6DJie09g== 33 507515057 600268686 132822896 2018-07-25 14:59:12
1 XjFwQcqOj/a3ca8uS3EUzA== 126 507515057 600268686 165867684 2020-05-06 20:37:36
2 A16SHlVkEdYzDYcuKAyKdQ== 34 507515057 600268686 132822186 2018-07-25 14:34:44
3 +A+12nfTw2I6vA3PNV0GDw== 125 507515057 600268686 148633856 2020-05-06 20:41:33
4 +A+12nfTw2I6vA3PNV0GDw== 141 507515057 600268686 167276694 2020-05-06 20:41:33
5 lRq7HdKfzTQkOokgrw809Q== 33 507515057 600268686 132866546 2018-07-27 20:51:22
6 aKI/VAmh+UP8KcE2Q5bXRg== 116 507515057 600268686 162288753 2020-05-06 21:23:28
7 +A+12nfTw2I6vA3PNV0GDw== 166 507515057 600268686 174096954 2020-05-06 20:41:33
8 vqkXsHSguUTB/tNx2xICkQ== 73 507515057 600268686 147624636 2020-02-17 08:55:44
9 +A+12nfTw2I6vA3PNV0GDw== 175 507515057 600268686 162286513 2020-05-06 20:41:33
10 XjFwQcqOj/a3ca8uS3EUzA== 237 507515057 600268686 162286313 2020-05-06 20:37:36
11 p878CnpgR+9mdq58o3nkhg== 64 507515057 600268686 147624646 2020-02-17 08:56:24

snapshot_linkedin_campaign_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "campaign_id"
-- Effective date columns are "last_updated_timestamp"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "encrypted_campaign_name",
    "campaign_version",
    "account_id",
    "campaign_group_id",
    "campaign_id",
    "creation_timestamp"
FROM (
     SELECT 
            "encrypted_campaign_name",
            "campaign_version",
            "account_id",
            "campaign_group_id",
            "campaign_id",
            "creation_timestamp",
            ROW_NUMBER() OVER (
                PARTITION BY "campaign_id" 
                ORDER BY "last_updated_timestamp" 
            DESC) AS "cocoon_rn"
    FROM "stg_linkedin_campaign_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_linkedin_campaign_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_linkedin_campaign_history_data
  description: The table is about current LinkedIn campaign data. It contains the
    latest information for each unique campaign, including encrypted campaign names,
    account IDs, campaign group IDs, and creation timestamps. It tracks the most recent
    version of each LinkedIn advertising campaign, excluding historical changes and
    version details.
  columns:
  - name: encrypted_campaign_name
    description: Encrypted name of the campaign
    tests:
    - not_null
  - name: campaign_version
    description: Version number of the campaign
    tests:
    - not_null
  - name: account_id
    description: Unique identifier for the LinkedIn advertising account
    tests:
    - not_null
  - name: campaign_group_id
    description: ID of the campaign group the campaign belongs to
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the specific campaign
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: creation_timestamp
    description: Timestamp when the campaign was initially created
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_linkedin_campaign_history_data

snapshot_linkedin_campaign_group_history_data (first 100 rows)

encrypted_group_name account_id campaign_group_id creation_timestamp
0 f7l0OENVPPPqyXqP9TMSCw== 507515057 602751036 2018-09-06 16:31:50
1 wpZy9D1VMXKii8s1G/8Umw== 507515057 600268686 2017-06-07 22:44:32
2 9eWX62RMpoodTvMVlpsIQw== 507515057 602018326 2018-05-18 00:49:23

snapshot_linkedin_campaign_group_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "campaign_group_id"
-- Effective date columns are "last_modified_timestamp"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "encrypted_group_name",
    "account_id",
    "campaign_group_id",
    "creation_timestamp"
FROM (
     SELECT 
            "encrypted_group_name",
            "account_id",
            "campaign_group_id",
            "creation_timestamp",
            ROW_NUMBER() OVER (
                PARTITION BY "campaign_group_id" 
                ORDER BY "last_modified_timestamp" 
            DESC) AS "cocoon_rn"
    FROM "stg_linkedin_campaign_group_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_linkedin_campaign_group_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_linkedin_campaign_group_history_data
  description: The table is about LinkedIn campaign groups. It tracks the most recent
    version of each campaign group. It contains the unique group ID, account ID, creation
    time, and encrypted name for each group. This snapshot represents the current
    state of campaign groups, without historical versions or modification timestamps.
  columns:
  - name: encrypted_group_name
    description: Encrypted name of the campaign group
    tests:
    - not_null
  - name: account_id
    description: LinkedIn account identifier
    tests:
    - not_null
  - name: campaign_group_id
    description: Unique identifier for the campaign group
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: creation_timestamp
    description: Timestamp of campaign group creation
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_linkedin_campaign_group_history_data

snapshot_linkedin_account_history_data (first 100 rows)

account_id encrypted_account_name account_currency revision_number account_creation_time
0 507515057 p6zp17DVJVjAD3VAr1btVw== USD 58 2017-06-07 22:44:32

snapshot_linkedin_account_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "account_id"
-- Effective date columns are "last_update_time"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "account_id",
    "encrypted_account_name",
    "account_currency",
    "revision_number",
    "account_creation_time"
FROM (
     SELECT 
            "account_id",
            "encrypted_account_name",
            "account_currency",
            "revision_number",
            "account_creation_time",
            ROW_NUMBER() OVER (
                PARTITION BY "account_id" 
                ORDER BY "last_update_time" 
            DESC) AS "cocoon_rn"
    FROM "stg_linkedin_account_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_linkedin_account_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_linkedin_account_history_data
  description: The table is about LinkedIn accounts. It tracks the most recent version
    of each account's details. The table includes the account ID, encrypted name,
    currency, and creation time. Each row represents the current state of a unique
    LinkedIn account. The data is simplified, showing only the latest information
    for each account without version history.
  columns:
  - name: account_id
    description: Unique identifier for the LinkedIn account
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: encrypted_account_name
    description: Encrypted name of the account holder
    tests:
    - not_null
  - name: account_currency
    description: Currency associated with the account
    tests:
    - not_null
  - name: revision_number
    description: Incremental number indicating account revision history
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the version number of the account, incrementing
        with each update. For this table, each row is a snapshot of the account at
        a different point in time. The revision_number is unique across rows as it
        increases with each update, making it a good identifier for each specific
        version of the account.
  - name: account_creation_time
    description: Timestamp when the account was initially created
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_linkedin_account_history_data
We identify the primary key (PK) and foreign key (FK) from tables. We build a join graph that connects FK to PK.

Join Graph (FK to PK)

%3 snapshot_linkedin_campaign_history_data snapshot_linkedin_campaign_history_data snapshot_linkedin_account_history_data snapshot_linkedin_account_history_data snapshot_linkedin_campaign_history_data->snapshot_linkedin_account_history_data snapshot_linkedin_campaign_group_history_data snapshot_linkedin_campaign_group_history_data snapshot_linkedin_campaign_history_data->snapshot_linkedin_campaign_group_history_data snapshot_linkedin_creative_history_data snapshot_linkedin_creative_history_data snapshot_linkedin_creative_history_data->snapshot_linkedin_campaign_history_data snapshot_linkedin_campaign_group_history_data->snapshot_linkedin_account_history_data stg_linkedin_ad_analytics_by_campaign_data stg_linkedin_ad_analytics_by_campaign_data stg_linkedin_ad_analytics_by_campaign_data->snapshot_linkedin_campaign_history_data stg_linkedin_ad_analytics_by_creative_data stg_linkedin_ad_analytics_by_creative_data stg_linkedin_ad_analytics_by_creative_data->snapshot_linkedin_creative_history_data

cocoon_join.yml (Document the joins)

join_graph:
- table_name: snapshot_linkedin_account_history_data
  primary_key: account_id
  foreign_keys: []
- table_name: snapshot_linkedin_campaign_group_history_data
  foreign_keys:
  - column: account_id
    reference:
      table_name: snapshot_linkedin_account_history_data
      column: account_id
  primary_key: campaign_group_id
- table_name: snapshot_linkedin_campaign_history_data
  foreign_keys:
  - column: account_id
    reference:
      table_name: snapshot_linkedin_account_history_data
      column: account_id
  - column: campaign_group_id
    reference:
      table_name: snapshot_linkedin_campaign_group_history_data
      column: campaign_group_id
  primary_key: campaign_id
- table_name: stg_linkedin_ad_analytics_by_campaign_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: snapshot_linkedin_campaign_history_data
      column: campaign_id
- table_name: snapshot_linkedin_creative_history_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: snapshot_linkedin_campaign_history_data
      column: campaign_id
  primary_key: creative_id
- table_name: stg_linkedin_ad_analytics_by_creative_data
  foreign_keys:
  - column: creative_id
    reference:
      table_name: snapshot_linkedin_creative_history_data
      column: creative_id
We identify the entities and relationships behind the tables, and tell the story among these relationships.

cocoon_er.yml (Document the ER model)

entities:
- entity_name: LinkedIn Accounts
  entity_description: Represents individual LinkedIn advertising accounts, containing
    current account details and identification information.
  table_name: snapshot_linkedin_account_history_data
  primary_key: account_id
- entity_name: LinkedIn Campaign Groups
  entity_description: Represents groups of related LinkedIn advertising campaigns,
    organizing campaigns under a common structure for an account.
  table_name: snapshot_linkedin_campaign_group_history_data
  primary_key: campaign_group_id
- entity_name: LinkedIn Campaigns
  entity_description: Represents individual LinkedIn advertising campaigns, containing
    current campaign details and associated account and group information.
  table_name: snapshot_linkedin_campaign_history_data
  primary_key: campaign_id
- entity_name: LinkedIn Creative Content
  entity_description: Represents individual creative content items used in LinkedIn
    advertising campaigns, including current status and associated campaign information.
  table_name: snapshot_linkedin_creative_history_data
  primary_key: creative_id
relations:
- relation_name: AccountCampaignGroups
  relation_description: LinkedIn Campaign Groups are created and managed within specific
    LinkedIn Accounts, with each group belonging to one account.
  table_name: snapshot_linkedin_campaign_group_history_data
  entities:
  - LinkedIn Campaign Groups
  - LinkedIn Accounts
- relation_name: AccountCampaignHierarchy
  relation_description: LinkedIn Campaigns are created within specific Campaign Groups,
    which belong to LinkedIn Accounts.
  table_name: snapshot_linkedin_campaign_history_data
  entities:
  - LinkedIn Campaigns
  - LinkedIn Accounts
  - LinkedIn Campaign Groups
- relation_name: CampaignCreativeContent
  relation_description: LinkedIn Creative Content is used within LinkedIn Campaigns
    for advertising purposes, tracking the latest version of each creative item.
  table_name: snapshot_linkedin_creative_history_data
  entities:
  - LinkedIn Creative Content
  - LinkedIn Campaigns
- relation_description: This table stores daily performance metrics and analytics
    for a specific LinkedIn ad campaign.
  table_name: stg_linkedin_ad_analytics_by_campaign_data
  entities:
  - LinkedIn Campaigns
- relation_description: This table tracks daily performance metrics for individual
    LinkedIn ad creatives, including costs and potential engagement data.
  table_name: stg_linkedin_ad_analytics_by_creative_data
  entities:
  - LinkedIn Creative Content
story:
- relation_name: AccountCampaignGroups
  story_line: LinkedIn Accounts contain multiple Campaign Groups for organization.
- relation_name: AccountCampaignHierarchy
  story_line: Campaign Groups house various Campaigns within LinkedIn Accounts.
- relation_name: CampaignCreativeContent
  story_line: Campaigns utilize Creative Content for advertising on LinkedIn.