Fivetran Pinterest

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

pinterest_ad_group_history_data (first 100 rows)

id campaign_id created_time name status start_time end_time _fivetran_synced pacing_delivery_type placement_group summary_status ad_account_id
0 2680065434898 626741793779 2020-03-26 09:38:46.000 +0000 9f8de0662581357b8af505197ad8145d ACTIVE 2020-03-26 09:37:00.000 +0000 NaN 2020-07-30 12:14:01.984 +0000 STANDARD ALL RUNNING 151515151
1 2680065434868 626741793779 2020-03-26 09:36:43.000 +0000 22a5457e096095c4e295a3c921db864c ACTIVE 2020-03-26 09:36:00.000 +0000 NaN 2020-07-30 12:14:01.246 +0000 STANDARD SEARCH RUNNING 151515151
2 2680065434863 626741793779 2020-03-26 09:35:49.000 +0000 5c7cdb607c2e540062914e276045d4d5 ACTIVE 2020-03-26 09:34:00.000 +0000 NaN 2020-07-30 12:14:00.867 +0000 STANDARD BROWSE RUNNING 151515151
3 2680065434881 626741793779 2020-03-26 09:37:17.000 +0000 304b2dc4ed50ff5b6d714b810d8b50cf ACTIVE 2020-03-26 09:36:00.000 +0000 NaN 2020-07-30 12:14:01.598 +0000 STANDARD OTHER RUNNING 151515151

pinterest_ad_group_report_data (first 100 rows)

ad_group_id advertiser_id date_ _fivetran_synced ad_group_name ad_group_status campaign_daily_spend_cap campaign_id campaign_lifetime_spend_cap campaign_name campaign_status clickthrough_1 clickthrough_1_gross cpc_in_micro_dollar cpm_in_micro_dollar ctr ecpc_in_micro_dollar ecpm_in_micro_dollar ectr engagement_1 impression_1 impression_1_gross outbound_click_1 paid_impression spend_in_micro_dollar total_engagement total_impression_frequency total_impression_user
0 2680072242253 549764253315 2022-06-07 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED NaN NaN NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 NaN 223 718556 NaN 1.173684 190
1 2680072242253 549764253315 2022-06-08 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED NaN NaN NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 NaN 1046 2437506 9.0 1.309136 799
2 2680072242253 549764253315 2022-06-14 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED NaN NaN NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 NaN 1208 2419523 2.0 1.017692 1187
3 2680072242253 549764253315 2022-06-15 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED NaN NaN NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 NaN 1209 2418809 4.0 1.085278 1114
4 2680072242253 549764253315 2022-06-10 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 1.0 1.0 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 NaN 1197 2424901 8.0 1.134597 1055
5 2680072242253 549764253315 2022-06-16 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 1.0 1.0 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 NaN 673 1346372 8.0 0.965567 697
6 2680072242253 549764253315 2022-06-09 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 1.0 1.0 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1.0 1038 2436977 16.0 1.098413 945
7 2680072242253 549764253315 2022-06-11 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 3.0 3.0 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1.0 1181 2433701 22.0 1.098605 1075
8 2680072242253 549764253315 2022-06-12 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 1.0 1.0 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1.0 1167 2425572 10.0 1.200617 972
9 2680072242253 549764253315 2022-06-13 00:00:00 2022-06-30 14:31:03 2022-06-07 14:30 | Ad group COMPLETED 0 626746449918 25000000 Cat Campaign: Brand Awareness COMPLETED 2.0 2.0 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 2.0 1185 2434974 15.0 1.070397 1108

pinterest_advertiser_history_data (first 100 rows)

id updated_time _fivetran_synced billing_profile_status billing_type country created_time currency merchant_id name owner_user_id status owner_username permissions
0 549764253315 2022-06-07 14:43:17 2022-06-30 14:01:04 VALID CASH_MONEY US 2022-06-07 14:17:13 USD NaN That Kitty Cat Company 1111111 ACTIVE username string

pinterest_advertiser_report_data (first 100 rows)

advertiser_id date_ _fivetran_synced clickthrough_1 clickthrough_1_gross cpc_in_micro_dollar cpm_in_micro_dollar ctr ecpc_in_micro_dollar ecpm_in_micro_dollar ectr engagement_1 impression_1 impression_1_gross outbound_click_1 paid_impression spend_in_micro_dollar total_engagement total_impression_frequency total_impression_user
0 549764253315 2022-06-15 00:00:00 2022-06-30 14:30:04 NaN NaN NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 NaN 1209 2418809 4.0 1.085278 1114
1 549764253315 2022-06-07 00:00:00 2022-06-30 14:30:04 NaN NaN NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 NaN 223 718556 NaN 1.173684 190
2 549764253315 2022-06-08 00:00:00 2022-06-30 14:30:04 NaN NaN NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 NaN 1046 2437506 9.0 1.309136 799
3 549764253315 2022-06-14 00:00:00 2022-06-30 14:30:04 NaN NaN NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 NaN 1208 2419523 2.0 1.017692 1187
4 549764253315 2022-06-10 00:00:00 2022-06-30 14:30:04 1.0 1.0 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 NaN 1197 2424901 8.0 1.134597 1055
5 549764253315 2022-06-16 00:00:00 2022-06-30 14:30:04 1.0 1.0 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 NaN 673 1346372 8.0 0.965567 697
6 549764253315 2022-06-11 00:00:00 2022-06-30 14:30:04 3.0 3.0 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1.0 1181 2433701 22.0 1.098605 1075
7 549764253315 2022-06-12 00:00:00 2022-06-30 14:30:04 1.0 1.0 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1.0 1167 2425572 10.0 1.200617 972
8 549764253315 2022-06-09 00:00:00 2022-06-30 14:30:04 1.0 1.0 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1.0 1038 2436977 16.0 1.098413 945
9 549764253315 2022-06-13 00:00:00 2022-06-30 14:30:04 2.0 2.0 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 2.0 1185 2434974 15.0 1.070397 1108

pinterest_campaign_history_data (first 100 rows)

id created_time name status _fivetran_synced advertiser_id default_ad_group_budget_in_micro_currency is_automated_campaign is_campaign_budget_optimization is_flexible_daily_budgets
0 626741793779 2020-03-26 08:59:57.000 +0000 19e757f946601de26307d8182635b716 ACTIVE 2020-07-30 12:14:00.362 +0000 151515151 134 True True True

pinterest_campaign_report_data (first 100 rows)

advertiser_id campaign_id date_ _fivetran_synced campaign_daily_spend_cap campaign_lifetime_spend_cap campaign_name campaign_status clickthrough_1 clickthrough_1_gross cpc_in_micro_dollar cpm_in_micro_dollar ctr ecpc_in_micro_dollar ecpm_in_micro_dollar ectr engagement_1 impression_1 impression_1_gross outbound_click_1 paid_impression spend_in_micro_dollar total_engagement total_impression_frequency total_impression_user
0 549764253315 626746449918 2022-06-08 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 NaN 1046 2437506 9.0 1.309136 799
1 549764253315 626746449918 2022-06-14 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 NaN 1208 2419523 2.0 1.017692 1187
2 549764253315 626746449918 2022-06-15 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 NaN 1209 2418809 4.0 1.085278 1114
3 549764253315 626746449918 2022-06-07 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 NaN 223 718556 NaN 1.173684 190
4 549764253315 626746449918 2022-06-10 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 1.0 1.0 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 NaN 1197 2424901 8.0 1.134597 1055
5 549764253315 626746449918 2022-06-16 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 1.0 1.0 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 NaN 673 1346372 8.0 0.965567 697
6 549764253315 626746449918 2022-06-11 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 3.0 3.0 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1.0 1181 2433701 22.0 1.098605 1075
7 549764253315 626746449918 2022-06-12 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 1.0 1.0 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1.0 1167 2425572 10.0 1.200617 972
8 549764253315 626746449918 2022-06-09 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 1.0 1.0 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1.0 1038 2436977 16.0 1.098413 945
9 549764253315 626746449918 2022-06-13 00:00:00 2022-06-30 14:10:07 0 25000000 My Cat Is Purrfect COMPLETED 2.0 2.0 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 2.0 1185 2434974 15.0 1.070397 1108

pinterest_keyword_history_data (first 100 rows)

_fivetran_id _fivetran_synced ad_group_id advertiser_id archived bid campaign_id id match_type parent_type value_
0 EzxgxB9EE6a6AMma/sqx0ZB4pPU= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206594 BROAD AD_GROUP development
1 wYse+Xtf2L/SnzThOMnxccXJaM4= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206590 BROAD AD_GROUP pasta
2 DauS5IYbqd9myiE2Sf48/gxdYtk= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206587 BROAD AD_GROUP gaming
3 dnYod6xOMc/p/1/vRVBmtHc9MOE= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206595 BROAD AD_GROUP game animals
4 e7sEbGLUh9M3kDrqPQRjk4VSEiU= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206586 BROAD AD_GROUP cat
5 WKo7cli6AW25q84txWkj0ElbNgc= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206593 BROAD AD_GROUP you
6 Rm9dXZR1BJWn52udNn+s1+hKXoc= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206589 BROAD AD_GROUP are
7 vRfN8m9pY6IRUVV8H7N9lQQaEYU= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206591 BROAD AD_GROUP curious
8 3wtluSTMp046Wxz/zVO0oh+Ldh4= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206592 BROAD AD_GROUP aren't
9 bVbQarPqKGBt68E4yzjc6GV/+tI= 2022-06-30 14:01:05 2680072242253 NaN False NaN NaN 2886843206588 BROAD AD_GROUP you

pinterest_keyword_report_data (first 100 rows)

ad_group_id advertiser_id campaign_id date_ keyword_id pin_id pin_promotion_id _fivetran_synced ad_group_name ad_group_status campaign_daily_spend_cap campaign_lifetime_spend_cap campaign_name campaign_status clickthrough_1 clickthrough_1_gross cpc_in_micro_dollar cpm_in_micro_dollar ctr ecpc_in_micro_dollar ecpm_in_micro_dollar ectr engagement_1 impression_1 impression_1_gross outbound_click_1 paid_impression pin_promotion_name pin_promotion_status spend_in_micro_dollar targeting_type targeting_value total_engagement
0 2680072242253 549764253315 626746449918 2022-06-10 00:00:00 2886843206586 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2009000.000 NaN NaN 2009000.000 NaN NaN 1 1 NaN 1 Awareness | Seriously My Cat is Amazing APPROVED 2009 KEYWORD cat NaN
1 2680072242253 549764253315 626746449918 2022-06-15 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000500.000 NaN NaN 2000500.000 NaN NaN 32 35 NaN 32 Awareness | Seriously My Cat is Amazing APPROVED 64016 KEYWORD gaming NaN
2 2680072242253 549764253315 626746449918 2022-06-16 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000333.333 NaN NaN 2000333.333 NaN NaN 12 13 NaN 12 Awareness | Seriously My Cat is Amazing APPROVED 24004 KEYWORD gaming NaN
3 2680072242253 549764253315 626746449918 2022-06-07 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 3246400.000 NaN NaN 3246400.000 NaN NaN 5 5 NaN 5 Awareness | Seriously My Cat is Amazing APPROVED 16232 KEYWORD gaming NaN
4 2680072242253 549764253315 626746449918 2022-06-10 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2031560.976 NaN NaN 2031560.976 NaN NaN 41 54 NaN 41 Awareness | Seriously My Cat is Amazing APPROVED 83294 KEYWORD gaming NaN
5 2680072242253 549764253315 626746449918 2022-06-12 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2092914.286 NaN NaN 2092914.286 NaN NaN 35 41 NaN 35 Awareness | Seriously My Cat is Amazing APPROVED 73252 KEYWORD gaming NaN
6 2680072242253 549764253315 626746449918 2022-06-13 00:00:00 2886843206587 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2058321.429 NaN NaN 2058321.429 NaN NaN 28 37 NaN 28 Awareness | Seriously My Cat is Amazing APPROVED 57633 KEYWORD gaming NaN
7 2680072242253 549764253315 626746449918 2022-06-15 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000448.276 NaN NaN 2000448.276 NaN NaN 87 102 NaN 87 Awareness | Seriously My Cat is Amazing APPROVED 174039 KEYWORD digital art NaN
8 2680072242253 549764253315 626746449918 2022-06-16 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2001375.000 NaN NaN 2001375.000 NaN NaN 32 34 NaN 32 Awareness | Seriously My Cat is Amazing APPROVED 64044 KEYWORD digital art NaN
9 2680072242253 549764253315 626746449918 2022-06-07 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 3218750.000 NaN NaN 3218750.000 NaN NaN 12 14 NaN 12 Awareness | Seriously My Cat is Amazing APPROVED 38625 KEYWORD digital art NaN
10 2680072242253 549764253315 626746449918 2022-06-08 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2306754.902 NaN NaN 2306754.902 NaN NaN 102 144 NaN 102 Awareness | Seriously My Cat is Amazing APPROVED 235289 KEYWORD digital art NaN
11 2680072242253 549764253315 626746449918 2022-06-09 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2353175.676 NaN NaN 2353175.676 NaN NaN 74 93 NaN 74 Awareness | Seriously My Cat is Amazing APPROVED 174135 KEYWORD digital art NaN
12 2680072242253 549764253315 626746449918 2022-06-10 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2034904.110 NaN NaN 2034904.110 NaN NaN 73 88 NaN 73 Awareness | Seriously My Cat is Amazing APPROVED 148548 KEYWORD digital art NaN
13 2680072242253 549764253315 626746449918 2022-06-11 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2072289.474 NaN NaN 2072289.474 NaN NaN 38 45 NaN 38 Awareness | Seriously My Cat is Amazing APPROVED 78747 KEYWORD digital art NaN
14 2680072242253 549764253315 626746449918 2022-06-12 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2090500.000 NaN NaN 2090500.000 NaN NaN 100 115 NaN 100 Awareness | Seriously My Cat is Amazing APPROVED 209050 KEYWORD digital art NaN
15 2680072242253 549764253315 626746449918 2022-06-14 00:00:00 2886843206589 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2002663.934 NaN NaN 2002663.934 NaN NaN 122 135 NaN 122 Awareness | Seriously My Cat is Amazing APPROVED 244325 KEYWORD digital art NaN
16 2680072242253 549764253315 626746449918 2022-06-15 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000521.739 NaN NaN 2000521.739 NaN NaN 46 53 NaN 46 Awareness | Seriously My Cat is Amazing APPROVED 92024 KEYWORD cat lover NaN
17 2680072242253 549764253315 626746449918 2022-06-16 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000400.000 NaN NaN 2000400.000 NaN NaN 15 16 NaN 15 Awareness | Seriously My Cat is Amazing APPROVED 30006 KEYWORD cat lover NaN
18 2680072242253 549764253315 626746449918 2022-06-07 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 3181000.000 NaN NaN 3181000.000 NaN NaN 5 7 NaN 5 Awareness | Seriously My Cat is Amazing APPROVED 15905 KEYWORD cat lover NaN
19 2680072242253 549764253315 626746449918 2022-06-08 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2319567.010 NaN NaN 2319567.010 NaN NaN 97 140 NaN 97 Awareness | Seriously My Cat is Amazing APPROVED 224998 KEYWORD cat lover NaN
20 2680072242253 549764253315 626746449918 2022-06-09 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2368694.737 NaN NaN 2368694.737 NaN NaN 95 111 NaN 95 Awareness | Seriously My Cat is Amazing APPROVED 225026 KEYWORD cat lover NaN
21 2680072242253 549764253315 626746449918 2022-06-10 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2025566.265 NaN NaN 2025566.265 NaN NaN 83 92 NaN 83 Awareness | Seriously My Cat is Amazing APPROVED 168122 KEYWORD cat lover NaN
22 2680072242253 549764253315 626746449918 2022-06-11 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2065142.857 NaN NaN 2065142.857 NaN NaN 56 63 NaN 56 Awareness | Seriously My Cat is Amazing APPROVED 115648 KEYWORD cat lover NaN
23 2680072242253 549764253315 626746449918 2022-06-12 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2114777.778 NaN NaN 2114777.778 NaN NaN 54 62 NaN 54 Awareness | Seriously My Cat is Amazing APPROVED 114198 KEYWORD cat lover NaN
24 2680072242253 549764253315 626746449918 2022-06-13 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2047761.905 NaN NaN 2047761.905 NaN NaN 42 47 NaN 42 Awareness | Seriously My Cat is Amazing APPROVED 86006 KEYWORD cat lover NaN
25 2680072242253 549764253315 626746449918 2022-06-14 00:00:00 2886843206592 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2002763.636 NaN NaN 2002763.636 NaN NaN 55 62 NaN 55 Awareness | Seriously My Cat is Amazing APPROVED 110152 KEYWORD cat lover NaN
26 2680072242253 549764253315 626746449918 2022-06-16 00:00:00 2886843206593 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000666.667 NaN NaN 2000666.667 NaN NaN 3 3 NaN 3 Awareness | Seriously My Cat is Amazing APPROVED 6002 KEYWORD cat drawing NaN
27 2680072242253 549764253315 626746449918 2022-06-10 00:00:00 2886843206593 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2018000.000 NaN NaN 2018000.000 NaN NaN 1 1 NaN 1 Awareness | Seriously My Cat is Amazing APPROVED 2018 KEYWORD cat drawing NaN
28 2680072242253 549764253315 626746449918 2022-06-15 00:00:00 2886843206594 1014646991029263265 687237616200 2022-06-30 14:11:01 2022-06-07 14:30 | Ad group COMPLETED 0 25000000 My Cat is Purrfect COMPLETED NaN NaN NaN 2000000.000 NaN NaN 2000000.000 NaN NaN 1 1 NaN 1 Awareness | Seriously My Cat is Amazing APPROVED 2000 KEYWORD development NaN

pinterest_pin_promotion_history_data (first 100 rows)

id ad_group_id created_time destination_url name pin_id status creative_type _fivetran_synced ad_account_id
0 687205395434 2680065434898 2020-03-26 09:38:46.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-30 12:14:03.098 +0000 549760489669
1 687205395435 2680065434898 2020-03-26 09:38:46.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216199 ACTIVE VIDEO 2020-07-30 12:14:03.098 +0000 549760489669
2 687205395433 2680065434898 2020-03-26 09:38:46.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216220 ACTIVE VIDEO 2020-07-30 12:14:03.097 +0000 549760489669
3 687205395404 2680065434881 2020-03-26 09:37:17.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216199 ACTIVE VIDEO 2020-07-30 12:14:03.097 +0000 549760489669
4 687205395403 2680065434881 2020-03-26 09:37:17.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-30 12:14:03.096 +0000 549760489669
5 687205395402 2680065434881 2020-03-26 09:37:17.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216220 ACTIVE VIDEO 2020-07-30 12:14:03.096 +0000 549760489669
6 687205395400 2680065434868 2020-03-26 09:36:43.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-30 12:14:03.095 +0000 549760489669
7 687205395401 2680065434868 2020-03-26 09:36:43.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216199 ACTIVE VIDEO 2020-07-30 12:14:03.095 +0000 549760489669
8 687205395399 2680065434868 2020-03-26 09:36:43.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216220 ACTIVE VIDEO 2020-07-30 12:14:03.094 +0000 549760489669
9 687205395389 2680065434863 2020-03-26 09:35:49.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216199 ACTIVE VIDEO 2020-07-30 12:14:03.094 +0000 549760489669
10 687205395388 2680065434863 2020-03-26 09:35:49.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-30 12:14:03.093 +0000 549760489669
11 687205395387 2680065434863 2020-03-26 09:35:49.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216220 ACTIVE VIDEO 2020-07-30 12:14:03.093 +0000 549760489669
12 687205395434 2680065434898 2020-03-26 09:38:46.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-24 00:14:18.647 +0000 549760489669
13 687205395388 2680065434863 2020-03-26 09:35:49.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-23 12:14:01.610 +0000 549760489669
14 687205395403 2680065434881 2020-03-26 09:37:17.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-07-01 12:14:37.616 +0000 549760489669
15 687205395434 2680065434898 2020-03-26 09:38:46.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-06-23 18:14:30.000 +0000 549760489669
16 687205395399 2680065434868 2020-03-26 09:36:43.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216220 ACTIVE VIDEO 2020-06-15 18:14:18.130 +0000 549760489669
17 687205395400 2680065434868 2020-03-26 09:36:43.000 +0000 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 848506386032216135 ACTIVE VIDEO 2020-05-28 06:14:04.150 +0000 549760489669

pinterest_pin_promotion_report_data (first 100 rows)

date_ pin_promotion_id ad_group_id campaign_id advertiser_id _fivetran_synced impression_1 impression_2 clickthrough_1 clickthrough_2 spend_in_micro_dollar
0 2020-04-20 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.558 +0000 5167 NaN 38.0 NaN 5898162.0
1 2020-04-20 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.558 +0000 607 1.0 14.0 NaN 2234418.0
2 2020-04-20 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.558 +0000 1169 NaN 4.0 NaN 594512.0
3 2020-04-19 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 3030 1.0 26.0 NaN 5775051.0
4 2020-04-19 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 1225 NaN 8.0 NaN 1475390.0
5 2020-04-14 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 1727 NaN 7.0 NaN 1690855.0
6 2020-04-14 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 2849 NaN 20.0 NaN 5757851.0
7 2020-04-14 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 846 NaN 1.0 NaN 233213.0
8 2020-04-19 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 3876 NaN 29.0 NaN 4692155.0
9 2020-04-19 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 2022 NaN 21.0 NaN 4164384.0
10 2020-04-19 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 1825 NaN 6.0 NaN 1143461.0
11 2020-04-14 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 580 NaN 7.0 NaN 1111999.0
12 2020-04-19 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 7026 1.0 52.0 NaN 7674653.0
13 2020-04-19 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 657 NaN 8.0 NaN 1180361.0
14 2020-04-19 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.557 +0000 703 NaN 6.0 NaN 884884.0
15 2020-04-18 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 3517 4.0 40.0 NaN 6586010.0
16 2020-04-18 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.555 +0000 847 NaN 6.0 NaN 931016.0
17 2020-04-13 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 1830 1.0 15.0 NaN 2953262.0
18 2020-04-13 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 2802 NaN 22.0 NaN 4424833.0
19 2020-04-13 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 471 1.0 7.0 NaN 1517985.0
20 2020-04-18 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 874 5.0 14.0 1.0 1358693.0
21 2020-04-18 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.555 +0000 509 NaN 10.0 NaN 1147648.0
22 2020-04-18 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.555 +0000 284 NaN 4.0 NaN 392207.0
23 2020-04-13 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 389 NaN 6.0 NaN 662529.0
24 2020-04-18 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 5959 NaN 61.0 NaN 7266432.0
25 2020-04-18 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 808 2.0 7.0 NaN 825940.0
26 2020-04-18 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.556 +0000 752 NaN 5.0 NaN 600236.0
27 2020-04-17 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.555 +0000 2968 9.0 30.0 NaN 5567327.0
28 2020-04-17 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 585 7.0 3.0 NaN 566654.0
29 2020-04-12 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 1672 NaN 12.0 NaN 2696639.0
30 2020-04-12 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 2572 NaN 26.0 NaN 6223112.0
31 2020-04-12 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 536 NaN 3.0 NaN 587721.0
32 2020-04-17 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 2124 NaN 25.0 NaN 4119453.0
33 2020-04-17 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 1865 NaN 24.0 NaN 4630370.0
34 2020-04-17 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 1031 NaN 7.0 NaN 1250177.0
35 2020-04-12 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 220 NaN 3.0 NaN 367035.0
36 2020-04-17 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.555 +0000 4321 6.0 40.0 NaN 5143164.0
37 2020-04-17 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 871 3.0 8.0 NaN 1004108.0
38 2020-04-17 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 793 NaN 2.0 NaN 276272.0
39 2020-04-16 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 3810 7.0 30.0 NaN 7329706.0
40 2020-04-16 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 1036 3.0 2.0 NaN 486117.0
41 2020-04-11 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 1144 NaN 13.0 NaN 2945035.0
42 2020-04-11 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 1689 NaN 19.0 NaN 4264461.0
43 2020-04-11 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 425 NaN 4.0 NaN 1114623.0
44 2020-04-16 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 1213 NaN 13.0 NaN 1913292.0
45 2020-04-16 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 1400 NaN 13.0 NaN 2073437.0
46 2020-04-16 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 777 NaN 8.0 NaN 1341305.0
47 2020-04-11 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 617 NaN 5.0 NaN 824458.0
48 2020-04-16 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.554 +0000 2766 4.0 31.0 NaN 3688330.0
49 2020-04-16 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 600 1.0 9.0 NaN 1218875.0
50 2020-04-16 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.553 +0000 425 NaN 4.0 NaN 544509.0
51 2020-04-15 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 3827 6.0 32.0 NaN 5339034.0
52 2020-04-15 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 751 NaN 10.0 NaN 1917879.0
53 2020-04-10 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.747 +0000 179 NaN 2.0 NaN 526437.0
54 2020-04-10 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.746 +0000 312 NaN 3.0 NaN 652527.0
55 2020-04-10 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.747 +0000 104 NaN NaN NaN NaN
56 2020-04-15 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 317 1.0 7.0 NaN 842516.0
57 2020-04-15 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.551 +0000 409 NaN 5.0 NaN 536052.0
58 2020-04-15 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 280 NaN 2.0 NaN 263558.0
59 2020-04-10 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.746 +0000 614 NaN 5.0 NaN 780497.0
60 2020-04-15 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 4604 5.0 59.0 NaN 8277440.0
61 2020-04-15 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 600 NaN 5.0 NaN 781651.0
62 2020-04-15 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:09:01.552 +0000 648 NaN 3.0 NaN 372523.0
63 2020-04-14 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 2358 10.0 19.0 NaN 3099178.0
64 2020-04-14 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 366 NaN 7.0 NaN 1228044.0
65 2020-04-09 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.745 +0000 1668 NaN 15.0 NaN 5153433.0
66 2020-04-09 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.745 +0000 1529 NaN 12.0 NaN 4262184.0
67 2020-04-09 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.745 +0000 373 NaN 1.0 NaN 434408.0
68 2020-04-14 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 2909 1.0 16.0 NaN 2736017.0
69 2020-04-14 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 2260 1.0 13.0 NaN 2286956.0
70 2020-04-14 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 1724 NaN 16.0 NaN 2708478.0
71 2020-04-09 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.745 +0000 1538 NaN 15.0 NaN 3050068.0
72 2020-04-14 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 6069 1.0 53.0 NaN 7142033.0
73 2020-04-14 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 896 NaN 6.0 NaN 848587.0
74 2020-04-14 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.751 +0000 725 NaN 6.0 NaN 873092.0
75 2020-04-13 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 1891 NaN 21.0 NaN 2583568.0
76 2020-04-13 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 309 NaN 2.0 NaN 192285.0
77 2020-04-08 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.744 +0000 715 NaN 5.0 NaN 1134079.0
78 2020-04-08 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.744 +0000 3341 2.0 28.0 NaN 6462223.0
79 2020-04-08 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.744 +0000 566 NaN 4.0 NaN 891960.0
80 2020-04-13 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 3354 NaN 29.0 NaN 4245250.0
81 2020-04-13 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 2836 NaN 28.0 NaN 3981054.0
82 2020-04-13 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 1618 NaN 11.0 NaN 1550929.0
83 2020-04-08 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.744 +0000 247 NaN 3.0 NaN 448669.0
84 2020-04-13 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 4142 5.0 50.0 NaN 5415223.0
85 2020-04-13 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 803 NaN 8.0 NaN 978657.0
86 2020-04-13 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.750 +0000 496 NaN 5.0 NaN 571428.0
87 2020-04-12 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 1580 2.0 21.0 NaN 2643718.0
88 2020-04-12 00:00:00 687205395401 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 231 NaN 2.0 NaN 272875.0
89 2020-04-07 00:00:00 687205395387 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.743 +0000 606 NaN 5.0 NaN 1125098.0
90 2020-04-07 00:00:00 687205395388 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.743 +0000 2030 NaN 20.0 NaN 3433488.0
91 2020-04-07 00:00:00 687205395389 2680065434863 626741793779 549760489669 2020-05-21 15:08:13.743 +0000 410 NaN 2.0 NaN 392749.0
92 2020-04-12 00:00:00 687205395402 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 2954 NaN 22.0 NaN 3081724.0
93 2020-04-12 00:00:00 687205395403 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 1939 1.0 32.0 NaN 4118203.0
94 2020-04-12 00:00:00 687205395404 2680065434881 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 1169 NaN 12.0 NaN 1872974.0
95 2020-04-07 00:00:00 687205395399 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.743 +0000 270 NaN 4.0 NaN 683477.0
96 2020-04-12 00:00:00 687205395433 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 3371 NaN 46.0 NaN 5727278.0
97 2020-04-12 00:00:00 687205395434 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 591 NaN 9.0 NaN 1007843.0
98 2020-04-12 00:00:00 687205395435 2680065434898 626741793779 549760489669 2020-05-21 15:08:13.749 +0000 420 NaN 5.0 NaN 532245.0
99 2020-04-11 00:00:00 687205395400 2680065434868 626741793779 549760489669 2020-05-21 15:08:13.748 +0000 2641 NaN 41.0 NaN 6549085.0
Source tables may have typos, unclear names, incorrect column types, etc. We clean these tables.

stg_pinterest_pin_promotion_history_data (first 100 rows)

landing_page_url campaign_name promotion_status creative_type ad_account_id ad_group_id creation_timestamp pin_id promoted_pin_id
0 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434881 2020-03-26 09:37:17+00:00 848506386032216135 687205395403
1 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434881 2020-03-26 09:37:17+00:00 848506386032216220 687205395402
2 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434868 2020-03-26 09:36:43+00:00 848506386032216135 687205395400
3 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434868 2020-03-26 09:36:43+00:00 848506386032216199 687205395401
4 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434863 2020-03-26 09:35:49+00:00 848506386032216135 687205395388
5 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434863 2020-03-26 09:35:49+00:00 848506386032216220 687205395387
6 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434898 2020-03-26 09:38:46+00:00 848506386032216135 687205395434
7 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434898 2020-03-26 09:38:46+00:00 848506386032216199 687205395435
8 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434881 2020-03-26 09:37:17+00:00 848506386032216199 687205395404
9 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434868 2020-03-26 09:36:43+00:00 848506386032216220 687205395399
10 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434863 2020-03-26 09:35:49+00:00 848506386032216199 687205395389
11 https://website.com/page?utm_source=sdfds 8d2b9c960e7bf8a6c22239377c1e6d81 ACTIVE VIDEO 549760489669 2680065434898 2020-03-26 09:38:46+00:00 848506386032216220 687205395433

stg_pinterest_pin_promotion_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_pin_promotion_history_data_projected" AS (
    -- Projection: Selecting 9 out of 10 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "ad_group_id",
        "created_time",
        "destination_url",
        "name",
        "pin_id",
        "status",
        "creative_type",
        "ad_account_id"
    FROM "pinterest_pin_promotion_history_data"
),

"pinterest_pin_promotion_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> promoted_pin_id
    -- created_time -> creation_timestamp
    -- destination_url -> landing_page_url
    -- name -> campaign_name
    -- status -> promotion_status
    SELECT 
        "id" AS "promoted_pin_id",
        "ad_group_id",
        "created_time" AS "creation_timestamp",
        "destination_url" AS "landing_page_url",
        "name" AS "campaign_name",
        "pin_id",
        "status" AS "promotion_status",
        "creative_type",
        "ad_account_id"
    FROM "pinterest_pin_promotion_history_data_projected"
),

"pinterest_pin_promotion_history_data_projected_renamed_dedup" AS (
    -- Deduplication: Removed 5 duplicated rows
    SELECT DISTINCT * FROM "pinterest_pin_promotion_history_data_projected_renamed"
),

"pinterest_pin_promotion_history_data_projected_renamed_dedup_casted" AS (
    -- Column Type Casting: 
    -- ad_account_id: from INT to VARCHAR
    -- ad_group_id: from INT to VARCHAR
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- pin_id: from INT to VARCHAR
    -- promoted_pin_id: from INT to VARCHAR
    SELECT
        "landing_page_url",
        "campaign_name",
        "promotion_status",
        "creative_type",
        CAST("ad_account_id" AS VARCHAR) AS "ad_account_id",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        strptime("creation_timestamp", '%Y-%m-%d %H:%M:%S.%f %z') AS "creation_timestamp",
        CAST("pin_id" AS VARCHAR) AS "pin_id",
        CAST("promoted_pin_id" AS VARCHAR) AS "promoted_pin_id"
    FROM "pinterest_pin_promotion_history_data_projected_renamed_dedup"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_pin_promotion_history_data_projected_renamed_dedup_casted"

stg_pinterest_pin_promotion_history_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_pin_promotion_history_data
  description: The table is about Pinterest pin promotion history data. It contains
    details of promoted pins including unique identifiers, ad group and account IDs,
    creation time, destination URL, pin name, pin ID, status, creative type, and ad
    account ID. Each row represents a specific pin promotion with its associated attributes
    and metadata.
  columns:
  - name: landing_page_url
    description: URL where users are directed upon clicking the pin
    tests:
    - not_null
  - name: campaign_name
    description: Name or identifier of the pin promotion campaign
    tests:
    - not_null
  - name: promotion_status
    description: Current status of the pin promotion
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - INACTIVE
        - PENDING
        - COMPLETED
        - SCHEDULED
        - CANCELLED
        - PAUSED
  - name: creative_type
    description: Type of creative content used in the promotion
    tests:
    - not_null
    - accepted_values:
        values:
        - VIDEO
        - IMAGE
        - TEXT
        - AUDIO
        - GIF
        - INFOGRAPHIC
        - CAROUSEL
        - SLIDESHOW
        - 360_VIDEO
        - LIVE_STREAM
        - ANIMATION
        - INTERACTIVE
        - AUGMENTED_REALITY
        - VIRTUAL_REALITY
  - name: ad_account_id
    description: Unique identifier for the advertising account
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
  - name: creation_timestamp
    description: Timestamp of when the pin promotion was created
    tests:
    - not_null
  - name: pin_id
    description: Unique identifier for the Pinterest pin being promoted
    tests:
    - not_null
  - name: promoted_pin_id
    description: Unique identifier for the promoted pin
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents a unique identifier for each promoted pin.
        For this table, each row is for a specific pin promotion. The promoted_pin_id
        appears to be unique across rows in the given sample data.

stg_pinterest_pin_promotion_report_data (first 100 rows)

primary_impressions secondary_impressions primary_clickthroughs secondary_clickthroughs spend_micro_dollars ad_group_id advertiser_id campaign_id date_ pin_promotion_id
0 5167 NaN 38.0 NaN 5898162.0 2680065434898 549760489669 626741793779 2020-04-20 687205395433
1 607 1.0 14.0 NaN 2234418.0 2680065434898 549760489669 626741793779 2020-04-20 687205395434
2 1169 NaN 4.0 NaN 594512.0 2680065434898 549760489669 626741793779 2020-04-20 687205395435
3 3030 1.0 26.0 NaN 5775051.0 2680065434868 549760489669 626741793779 2020-04-19 687205395400
4 1225 NaN 8.0 NaN 1475390.0 2680065434868 549760489669 626741793779 2020-04-19 687205395401
5 1727 NaN 7.0 NaN 1690855.0 2680065434863 549760489669 626741793779 2020-04-14 687205395387
6 2849 NaN 20.0 NaN 5757851.0 2680065434863 549760489669 626741793779 2020-04-14 687205395388
7 846 NaN 1.0 NaN 233213.0 2680065434863 549760489669 626741793779 2020-04-14 687205395389
8 3876 NaN 29.0 NaN 4692155.0 2680065434881 549760489669 626741793779 2020-04-19 687205395402
9 2022 NaN 21.0 NaN 4164384.0 2680065434881 549760489669 626741793779 2020-04-19 687205395403
10 1825 NaN 6.0 NaN 1143461.0 2680065434881 549760489669 626741793779 2020-04-19 687205395404
11 580 NaN 7.0 NaN 1111999.0 2680065434868 549760489669 626741793779 2020-04-14 687205395399
12 7026 1.0 52.0 NaN 7674653.0 2680065434898 549760489669 626741793779 2020-04-19 687205395433
13 657 NaN 8.0 NaN 1180361.0 2680065434898 549760489669 626741793779 2020-04-19 687205395434
14 703 NaN 6.0 NaN 884884.0 2680065434898 549760489669 626741793779 2020-04-19 687205395435
15 3517 4.0 40.0 NaN 6586010.0 2680065434868 549760489669 626741793779 2020-04-18 687205395400
16 847 NaN 6.0 NaN 931016.0 2680065434868 549760489669 626741793779 2020-04-18 687205395401
17 1830 1.0 15.0 NaN 2953262.0 2680065434863 549760489669 626741793779 2020-04-13 687205395387
18 2802 NaN 22.0 NaN 4424833.0 2680065434863 549760489669 626741793779 2020-04-13 687205395388
19 471 1.0 7.0 NaN 1517985.0 2680065434863 549760489669 626741793779 2020-04-13 687205395389
20 874 5.0 14.0 1.0 1358693.0 2680065434881 549760489669 626741793779 2020-04-18 687205395402
21 509 NaN 10.0 NaN 1147648.0 2680065434881 549760489669 626741793779 2020-04-18 687205395403
22 284 NaN 4.0 NaN 392207.0 2680065434881 549760489669 626741793779 2020-04-18 687205395404
23 389 NaN 6.0 NaN 662529.0 2680065434868 549760489669 626741793779 2020-04-13 687205395399
24 5959 NaN 61.0 NaN 7266432.0 2680065434898 549760489669 626741793779 2020-04-18 687205395433
25 808 2.0 7.0 NaN 825940.0 2680065434898 549760489669 626741793779 2020-04-18 687205395434
26 752 NaN 5.0 NaN 600236.0 2680065434898 549760489669 626741793779 2020-04-18 687205395435
27 2968 9.0 30.0 NaN 5567327.0 2680065434868 549760489669 626741793779 2020-04-17 687205395400
28 585 7.0 3.0 NaN 566654.0 2680065434868 549760489669 626741793779 2020-04-17 687205395401
29 1672 NaN 12.0 NaN 2696639.0 2680065434863 549760489669 626741793779 2020-04-12 687205395387
30 2572 NaN 26.0 NaN 6223112.0 2680065434863 549760489669 626741793779 2020-04-12 687205395388
31 536 NaN 3.0 NaN 587721.0 2680065434863 549760489669 626741793779 2020-04-12 687205395389
32 2124 NaN 25.0 NaN 4119453.0 2680065434881 549760489669 626741793779 2020-04-17 687205395402
33 1865 NaN 24.0 NaN 4630370.0 2680065434881 549760489669 626741793779 2020-04-17 687205395403
34 1031 NaN 7.0 NaN 1250177.0 2680065434881 549760489669 626741793779 2020-04-17 687205395404
35 220 NaN 3.0 NaN 367035.0 2680065434868 549760489669 626741793779 2020-04-12 687205395399
36 4321 6.0 40.0 NaN 5143164.0 2680065434898 549760489669 626741793779 2020-04-17 687205395433
37 871 3.0 8.0 NaN 1004108.0 2680065434898 549760489669 626741793779 2020-04-17 687205395434
38 793 NaN 2.0 NaN 276272.0 2680065434898 549760489669 626741793779 2020-04-17 687205395435
39 3810 7.0 30.0 NaN 7329706.0 2680065434868 549760489669 626741793779 2020-04-16 687205395400
40 1036 3.0 2.0 NaN 486117.0 2680065434868 549760489669 626741793779 2020-04-16 687205395401
41 1144 NaN 13.0 NaN 2945035.0 2680065434863 549760489669 626741793779 2020-04-11 687205395387
42 1689 NaN 19.0 NaN 4264461.0 2680065434863 549760489669 626741793779 2020-04-11 687205395388
43 425 NaN 4.0 NaN 1114623.0 2680065434863 549760489669 626741793779 2020-04-11 687205395389
44 1213 NaN 13.0 NaN 1913292.0 2680065434881 549760489669 626741793779 2020-04-16 687205395402
45 1400 NaN 13.0 NaN 2073437.0 2680065434881 549760489669 626741793779 2020-04-16 687205395403
46 777 NaN 8.0 NaN 1341305.0 2680065434881 549760489669 626741793779 2020-04-16 687205395404
47 617 NaN 5.0 NaN 824458.0 2680065434868 549760489669 626741793779 2020-04-11 687205395399
48 2766 4.0 31.0 NaN 3688330.0 2680065434898 549760489669 626741793779 2020-04-16 687205395433
49 600 1.0 9.0 NaN 1218875.0 2680065434898 549760489669 626741793779 2020-04-16 687205395434
50 425 NaN 4.0 NaN 544509.0 2680065434898 549760489669 626741793779 2020-04-16 687205395435
51 3827 6.0 32.0 NaN 5339034.0 2680065434868 549760489669 626741793779 2020-04-15 687205395400
52 751 NaN 10.0 NaN 1917879.0 2680065434868 549760489669 626741793779 2020-04-15 687205395401
53 179 NaN 2.0 NaN 526437.0 2680065434863 549760489669 626741793779 2020-04-10 687205395387
54 312 NaN 3.0 NaN 652527.0 2680065434863 549760489669 626741793779 2020-04-10 687205395388
55 104 NaN NaN NaN NaN 2680065434863 549760489669 626741793779 2020-04-10 687205395389
56 317 1.0 7.0 NaN 842516.0 2680065434881 549760489669 626741793779 2020-04-15 687205395402
57 409 NaN 5.0 NaN 536052.0 2680065434881 549760489669 626741793779 2020-04-15 687205395403
58 280 NaN 2.0 NaN 263558.0 2680065434881 549760489669 626741793779 2020-04-15 687205395404
59 614 NaN 5.0 NaN 780497.0 2680065434868 549760489669 626741793779 2020-04-10 687205395399
60 4604 5.0 59.0 NaN 8277440.0 2680065434898 549760489669 626741793779 2020-04-15 687205395433
61 600 NaN 5.0 NaN 781651.0 2680065434898 549760489669 626741793779 2020-04-15 687205395434
62 648 NaN 3.0 NaN 372523.0 2680065434898 549760489669 626741793779 2020-04-15 687205395435
63 2358 10.0 19.0 NaN 3099178.0 2680065434868 549760489669 626741793779 2020-04-14 687205395400
64 366 NaN 7.0 NaN 1228044.0 2680065434868 549760489669 626741793779 2020-04-14 687205395401
65 1668 NaN 15.0 NaN 5153433.0 2680065434863 549760489669 626741793779 2020-04-09 687205395387
66 1529 NaN 12.0 NaN 4262184.0 2680065434863 549760489669 626741793779 2020-04-09 687205395388
67 373 NaN 1.0 NaN 434408.0 2680065434863 549760489669 626741793779 2020-04-09 687205395389
68 2909 1.0 16.0 NaN 2736017.0 2680065434881 549760489669 626741793779 2020-04-14 687205395402
69 2260 1.0 13.0 NaN 2286956.0 2680065434881 549760489669 626741793779 2020-04-14 687205395403
70 1724 NaN 16.0 NaN 2708478.0 2680065434881 549760489669 626741793779 2020-04-14 687205395404
71 1538 NaN 15.0 NaN 3050068.0 2680065434868 549760489669 626741793779 2020-04-09 687205395399
72 6069 1.0 53.0 NaN 7142033.0 2680065434898 549760489669 626741793779 2020-04-14 687205395433
73 896 NaN 6.0 NaN 848587.0 2680065434898 549760489669 626741793779 2020-04-14 687205395434
74 725 NaN 6.0 NaN 873092.0 2680065434898 549760489669 626741793779 2020-04-14 687205395435
75 1891 NaN 21.0 NaN 2583568.0 2680065434868 549760489669 626741793779 2020-04-13 687205395400
76 309 NaN 2.0 NaN 192285.0 2680065434868 549760489669 626741793779 2020-04-13 687205395401
77 715 NaN 5.0 NaN 1134079.0 2680065434863 549760489669 626741793779 2020-04-08 687205395387
78 3341 2.0 28.0 NaN 6462223.0 2680065434863 549760489669 626741793779 2020-04-08 687205395388
79 566 NaN 4.0 NaN 891960.0 2680065434863 549760489669 626741793779 2020-04-08 687205395389
80 3354 NaN 29.0 NaN 4245250.0 2680065434881 549760489669 626741793779 2020-04-13 687205395402
81 2836 NaN 28.0 NaN 3981054.0 2680065434881 549760489669 626741793779 2020-04-13 687205395403
82 1618 NaN 11.0 NaN 1550929.0 2680065434881 549760489669 626741793779 2020-04-13 687205395404
83 247 NaN 3.0 NaN 448669.0 2680065434868 549760489669 626741793779 2020-04-08 687205395399
84 4142 5.0 50.0 NaN 5415223.0 2680065434898 549760489669 626741793779 2020-04-13 687205395433
85 803 NaN 8.0 NaN 978657.0 2680065434898 549760489669 626741793779 2020-04-13 687205395434
86 496 NaN 5.0 NaN 571428.0 2680065434898 549760489669 626741793779 2020-04-13 687205395435
87 1580 2.0 21.0 NaN 2643718.0 2680065434868 549760489669 626741793779 2020-04-12 687205395400
88 231 NaN 2.0 NaN 272875.0 2680065434868 549760489669 626741793779 2020-04-12 687205395401
89 606 NaN 5.0 NaN 1125098.0 2680065434863 549760489669 626741793779 2020-04-07 687205395387
90 2030 NaN 20.0 NaN 3433488.0 2680065434863 549760489669 626741793779 2020-04-07 687205395388
91 410 NaN 2.0 NaN 392749.0 2680065434863 549760489669 626741793779 2020-04-07 687205395389
92 2954 NaN 22.0 NaN 3081724.0 2680065434881 549760489669 626741793779 2020-04-12 687205395402
93 1939 1.0 32.0 NaN 4118203.0 2680065434881 549760489669 626741793779 2020-04-12 687205395403
94 1169 NaN 12.0 NaN 1872974.0 2680065434881 549760489669 626741793779 2020-04-12 687205395404
95 270 NaN 4.0 NaN 683477.0 2680065434868 549760489669 626741793779 2020-04-07 687205395399
96 3371 NaN 46.0 NaN 5727278.0 2680065434898 549760489669 626741793779 2020-04-12 687205395433
97 591 NaN 9.0 NaN 1007843.0 2680065434898 549760489669 626741793779 2020-04-12 687205395434
98 420 NaN 5.0 NaN 532245.0 2680065434898 549760489669 626741793779 2020-04-12 687205395435
99 2641 NaN 41.0 NaN 6549085.0 2680065434868 549760489669 626741793779 2020-04-11 687205395400

stg_pinterest_pin_promotion_report_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_pin_promotion_report_data_projected" AS (
    -- Projection: Selecting 10 out of 11 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "date_",
        "pin_promotion_id",
        "ad_group_id",
        "campaign_id",
        "advertiser_id",
        "impression_1",
        "impression_2",
        "clickthrough_1",
        "clickthrough_2",
        "spend_in_micro_dollar"
    FROM "pinterest_pin_promotion_report_data"
),

"pinterest_pin_promotion_report_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- impression_1 -> primary_impressions
    -- impression_2 -> secondary_impressions
    -- clickthrough_1 -> primary_clickthroughs
    -- clickthrough_2 -> secondary_clickthroughs
    -- spend_in_micro_dollar -> spend_micro_dollars
    SELECT 
        "date_",
        "pin_promotion_id",
        "ad_group_id",
        "campaign_id",
        "advertiser_id",
        "impression_1" AS "primary_impressions",
        "impression_2" AS "secondary_impressions",
        "clickthrough_1" AS "primary_clickthroughs",
        "clickthrough_2" AS "secondary_clickthroughs",
        "spend_in_micro_dollar" AS "spend_micro_dollars"
    FROM "pinterest_pin_promotion_report_data_projected"
),

"pinterest_pin_promotion_report_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- ad_group_id: from INT to VARCHAR
    -- advertiser_id: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- date_: from VARCHAR to TIMESTAMP
    -- pin_promotion_id: from INT to VARCHAR
    SELECT
        "primary_impressions",
        "secondary_impressions",
        "primary_clickthroughs",
        "secondary_clickthroughs",
        "spend_micro_dollars",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("date_" AS TIMESTAMP) AS "date_",
        CAST("pin_promotion_id" AS VARCHAR) AS "pin_promotion_id"
    FROM "pinterest_pin_promotion_report_data_projected_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_pin_promotion_report_data_projected_renamed_casted"

stg_pinterest_pin_promotion_report_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_pin_promotion_report_data
  description: The table is about Pinterest pin promotion performance data. It contains
    daily metrics for individual promoted pins. Each row includes the date, pin promotion
    ID, ad group ID, campaign ID, advertiser ID, impression counts, clickthrough counts,
    and spend amount. The data allows tracking and analysis of pin promotion effectiveness
    and costs over time.
  columns:
  - name: primary_impressions
    description: Number of primary impressions
    tests:
    - not_null
  - name: secondary_impressions
    description: Number of secondary impressions
    cocoon_meta:
      missing_acceptable: No secondary impressions occurred for that ad interaction
  - name: primary_clickthroughs
    description: Number of primary clickthroughs
    tests:
    - not_null
  - name: secondary_clickthroughs
    description: Number of secondary clickthroughs
    cocoon_meta:
      missing_acceptable: No secondary clicks occurred for that ad interaction
  - name: spend_micro_dollars
    description: Amount spent in micro dollars
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: date_
    description: Date of the recorded data
    tests:
    - not_null
  - name: pin_promotion_id
    description: Unique identifier for the promoted pin
    tests:
    - not_null

stg_pinterest_ad_group_history_data (first 100 rows)

ad_group_name ad_group_status pacing_delivery_type placement_group summary_status ad_account_id ad_group_id campaign_id creation_timestamp end_timestamp start_timestamp
0 9f8de0662581357b8af505197ad8145d ACTIVE STANDARD ALL RUNNING 151515151 2680065434898 626741793779 2020-03-26 09:38:46+00:00 NaT 2020-03-26 09:37:00
1 22a5457e096095c4e295a3c921db864c ACTIVE STANDARD SEARCH RUNNING 151515151 2680065434868 626741793779 2020-03-26 09:36:43+00:00 NaT 2020-03-26 09:36:00
2 5c7cdb607c2e540062914e276045d4d5 ACTIVE STANDARD BROWSE RUNNING 151515151 2680065434863 626741793779 2020-03-26 09:35:49+00:00 NaT 2020-03-26 09:34:00
3 304b2dc4ed50ff5b6d714b810d8b50cf ACTIVE STANDARD OTHER RUNNING 151515151 2680065434881 626741793779 2020-03-26 09:37:17+00:00 NaT 2020-03-26 09:36:00

stg_pinterest_ad_group_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_ad_group_history_data_projected" AS (
    -- Projection: Selecting 11 out of 12 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "campaign_id",
        "created_time",
        "name",
        "status",
        "start_time",
        "end_time",
        "pacing_delivery_type",
        "placement_group",
        "summary_status",
        "ad_account_id"
    FROM "pinterest_ad_group_history_data"
),

"pinterest_ad_group_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> ad_group_id
    -- created_time -> creation_timestamp
    -- name -> ad_group_name
    -- status -> ad_group_status
    -- start_time -> start_timestamp
    -- end_time -> end_timestamp
    SELECT 
        "id" AS "ad_group_id",
        "campaign_id",
        "created_time" AS "creation_timestamp",
        "name" AS "ad_group_name",
        "status" AS "ad_group_status",
        "start_time" AS "start_timestamp",
        "end_time" AS "end_timestamp",
        "pacing_delivery_type",
        "placement_group",
        "summary_status",
        "ad_account_id"
    FROM "pinterest_ad_group_history_data_projected"
),

"pinterest_ad_group_history_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- ad_account_id: from INT to VARCHAR
    -- ad_group_id: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- creation_timestamp: from VARCHAR to TIMESTAMP
    -- end_timestamp: from DECIMAL to TIMESTAMP
    -- start_timestamp: from VARCHAR to TIMESTAMP
    SELECT
        "ad_group_name",
        "ad_group_status",
        "pacing_delivery_type",
        "placement_group",
        "summary_status",
        CAST("ad_account_id" AS VARCHAR) AS "ad_account_id",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        strptime("creation_timestamp", '%Y-%m-%d %H:%M:%S.%f %z') AS "creation_timestamp",
        CAST("end_timestamp" AS TIMESTAMP) AS "end_timestamp",
        CAST(strptime(SUBSTRING("start_timestamp", 1, 23), '%Y-%m-%d %H:%M:%S.%f') AS TIMESTAMP) AS "start_timestamp"
    FROM "pinterest_ad_group_history_data_projected_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_ad_group_history_data_projected_renamed_casted"

stg_pinterest_ad_group_history_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_ad_group_history_data
  description: The table is about Pinterest ad group history data. It contains details
    of ad groups, including their ID, campaign ID, creation time, name, status, start
    and end times, pacing delivery type, placement group, summary status, and associated
    ad account ID. Each row represents a unique ad group with its specific attributes
    and settings.
  columns:
  - name: ad_group_name
    description: Name or identifier of the ad group
    tests:
    - not_null
  - name: ad_group_status
    description: Current status of the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - PAUSED
        - REMOVED
        - PENDING
        - DELETED
  - name: pacing_delivery_type
    description: Type of pacing delivery for the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - STANDARD
        - ACCELERATED
        - EVEN
  - name: placement_group
    description: Group where the ad is placed
    tests:
    - not_null
    - accepted_values:
        values:
        - ALL
        - BROWSE
        - OTHER
        - SEARCH
        - HOME
        - FEED
        - PROFILE
        - VIDEO
        - STORIES
        - MARKETPLACE
        - EVENTS
        - GROUPS
        - MESSENGER
        - NEWS
        - APPS
        - GAMES
  - name: summary_status
    description: Summary of the ad group's overall status
    tests:
    - not_null
    - accepted_values:
        values:
        - RUNNING
        - PAUSED
        - REMOVED
        - ENABLED
        - DISABLED
        - PENDING
        - ENDED
        - ARCHIVED
  - name: ad_account_id
    description: Unique identifier for the ad account
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is the unique identifier for the ad group. For this
        table, each row represents a unique ad group. Ad group IDs are typically designed
        to be unique across the entire system.
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: creation_timestamp
    description: Timestamp when the ad group was created
    tests:
    - not_null
  - name: end_timestamp
    description: Timestamp when the ad group ends
    cocoon_meta:
      missing_acceptable: Not applicable for currently active/running ad groups.
  - name: start_timestamp
    description: Timestamp when the ad group starts
    tests:
    - not_null

stg_pinterest_keyword_report_data (first 100 rows)

ad_group_name ad_group_status campaign_name campaign_status cost_per_mille_micro effective_cost_per_mille_micro impression_count impression_count_gross paid_impression_count pin_promotion_name pin_promotion_status spend_micro targeting_type keyword_category ad_group_id advertiser_id campaign_daily_spend_cap campaign_id campaign_lifetime_spend_cap keyword_id performance_date pin_id pin_promotion_id
0 Ad group COMPLETED My Cat is Purrfect COMPLETED 2009000.000 2009000.000 1 1 1 Awareness | Seriously My Cat is Amazing APPROVED 2009 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206586 2022-06-10 1014646991029263265 687237616200
1 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000500.000 2000500.000 32 35 32 Awareness | Seriously My Cat is Amazing APPROVED 64016 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-15 1014646991029263265 687237616200
2 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000333.333 2000333.333 12 13 12 Awareness | Seriously My Cat is Amazing APPROVED 24004 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-16 1014646991029263265 687237616200
3 Ad group COMPLETED My Cat is Purrfect COMPLETED 3246400.000 3246400.000 5 5 5 Awareness | Seriously My Cat is Amazing APPROVED 16232 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-07 1014646991029263265 687237616200
4 Ad group COMPLETED My Cat is Purrfect COMPLETED 2031560.976 2031560.976 41 54 41 Awareness | Seriously My Cat is Amazing APPROVED 83294 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-10 1014646991029263265 687237616200
5 Ad group COMPLETED My Cat is Purrfect COMPLETED 2092914.286 2092914.286 35 41 35 Awareness | Seriously My Cat is Amazing APPROVED 73252 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-12 1014646991029263265 687237616200
6 Ad group COMPLETED My Cat is Purrfect COMPLETED 2058321.429 2058321.429 28 37 28 Awareness | Seriously My Cat is Amazing APPROVED 57633 KEYWORD gaming 2680072242253 549764253315 0 626746449918 25000000 2886843206587 2022-06-13 1014646991029263265 687237616200
7 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000448.276 2000448.276 87 102 87 Awareness | Seriously My Cat is Amazing APPROVED 174039 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-15 1014646991029263265 687237616200
8 Ad group COMPLETED My Cat is Purrfect COMPLETED 2001375.000 2001375.000 32 34 32 Awareness | Seriously My Cat is Amazing APPROVED 64044 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-16 1014646991029263265 687237616200
9 Ad group COMPLETED My Cat is Purrfect COMPLETED 3218750.000 3218750.000 12 14 12 Awareness | Seriously My Cat is Amazing APPROVED 38625 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-07 1014646991029263265 687237616200
10 Ad group COMPLETED My Cat is Purrfect COMPLETED 2306754.902 2306754.902 102 144 102 Awareness | Seriously My Cat is Amazing APPROVED 235289 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-08 1014646991029263265 687237616200
11 Ad group COMPLETED My Cat is Purrfect COMPLETED 2353175.676 2353175.676 74 93 74 Awareness | Seriously My Cat is Amazing APPROVED 174135 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-09 1014646991029263265 687237616200
12 Ad group COMPLETED My Cat is Purrfect COMPLETED 2034904.110 2034904.110 73 88 73 Awareness | Seriously My Cat is Amazing APPROVED 148548 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-10 1014646991029263265 687237616200
13 Ad group COMPLETED My Cat is Purrfect COMPLETED 2072289.474 2072289.474 38 45 38 Awareness | Seriously My Cat is Amazing APPROVED 78747 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-11 1014646991029263265 687237616200
14 Ad group COMPLETED My Cat is Purrfect COMPLETED 2090500.000 2090500.000 100 115 100 Awareness | Seriously My Cat is Amazing APPROVED 209050 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-12 1014646991029263265 687237616200
15 Ad group COMPLETED My Cat is Purrfect COMPLETED 2002663.934 2002663.934 122 135 122 Awareness | Seriously My Cat is Amazing APPROVED 244325 KEYWORD digital art 2680072242253 549764253315 0 626746449918 25000000 2886843206589 2022-06-14 1014646991029263265 687237616200
16 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000521.739 2000521.739 46 53 46 Awareness | Seriously My Cat is Amazing APPROVED 92024 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-15 1014646991029263265 687237616200
17 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000400.000 2000400.000 15 16 15 Awareness | Seriously My Cat is Amazing APPROVED 30006 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-16 1014646991029263265 687237616200
18 Ad group COMPLETED My Cat is Purrfect COMPLETED 3181000.000 3181000.000 5 7 5 Awareness | Seriously My Cat is Amazing APPROVED 15905 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-07 1014646991029263265 687237616200
19 Ad group COMPLETED My Cat is Purrfect COMPLETED 2319567.010 2319567.010 97 140 97 Awareness | Seriously My Cat is Amazing APPROVED 224998 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-08 1014646991029263265 687237616200
20 Ad group COMPLETED My Cat is Purrfect COMPLETED 2368694.737 2368694.737 95 111 95 Awareness | Seriously My Cat is Amazing APPROVED 225026 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-09 1014646991029263265 687237616200
21 Ad group COMPLETED My Cat is Purrfect COMPLETED 2025566.265 2025566.265 83 92 83 Awareness | Seriously My Cat is Amazing APPROVED 168122 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-10 1014646991029263265 687237616200
22 Ad group COMPLETED My Cat is Purrfect COMPLETED 2065142.857 2065142.857 56 63 56 Awareness | Seriously My Cat is Amazing APPROVED 115648 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-11 1014646991029263265 687237616200
23 Ad group COMPLETED My Cat is Purrfect COMPLETED 2114777.778 2114777.778 54 62 54 Awareness | Seriously My Cat is Amazing APPROVED 114198 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-12 1014646991029263265 687237616200
24 Ad group COMPLETED My Cat is Purrfect COMPLETED 2047761.905 2047761.905 42 47 42 Awareness | Seriously My Cat is Amazing APPROVED 86006 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-13 1014646991029263265 687237616200
25 Ad group COMPLETED My Cat is Purrfect COMPLETED 2002763.636 2002763.636 55 62 55 Awareness | Seriously My Cat is Amazing APPROVED 110152 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206592 2022-06-14 1014646991029263265 687237616200
26 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000666.667 2000666.667 3 3 3 Awareness | Seriously My Cat is Amazing APPROVED 6002 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206593 2022-06-16 1014646991029263265 687237616200
27 Ad group COMPLETED My Cat is Purrfect COMPLETED 2018000.000 2018000.000 1 1 1 Awareness | Seriously My Cat is Amazing APPROVED 2018 KEYWORD cat lover 2680072242253 549764253315 0 626746449918 25000000 2886843206593 2022-06-10 1014646991029263265 687237616200
28 Ad group COMPLETED My Cat is Purrfect COMPLETED 2000000.000 2000000.000 1 1 1 Awareness | Seriously My Cat is Amazing APPROVED 2000 KEYWORD development 2680072242253 549764253315 0 626746449918 25000000 2886843206594 2022-06-15 1014646991029263265 687237616200

stg_pinterest_keyword_report_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_keyword_report_data_projected" AS (
    -- Projection: Selecting 32 out of 33 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "ad_group_id",
        "advertiser_id",
        "campaign_id",
        "date_",
        "keyword_id",
        "pin_id",
        "pin_promotion_id",
        "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_1",
        "clickthrough_1_gross",
        "cpc_in_micro_dollar",
        "cpm_in_micro_dollar",
        "ctr",
        "ecpc_in_micro_dollar",
        "ecpm_in_micro_dollar",
        "ectr",
        "engagement_1",
        "impression_1",
        "impression_1_gross",
        "outbound_click_1",
        "paid_impression",
        "pin_promotion_name",
        "pin_promotion_status",
        "spend_in_micro_dollar",
        "targeting_type",
        "targeting_value",
        "total_engagement"
    FROM "pinterest_keyword_report_data"
),

"pinterest_keyword_report_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- date_ -> performance_date
    -- clickthrough_1 -> clickthrough_count
    -- clickthrough_1_gross -> clickthrough_count_gross
    -- cpc_in_micro_dollar -> cost_per_click_micro
    -- cpm_in_micro_dollar -> cost_per_mille_micro
    -- ctr -> click_through_rate
    -- ecpc_in_micro_dollar -> effective_cost_per_click_micro
    -- ecpm_in_micro_dollar -> effective_cost_per_mille_micro
    -- ectr -> effective_click_through_rate
    -- engagement_1 -> engagement_count
    -- impression_1 -> impression_count
    -- impression_1_gross -> impression_count_gross
    -- outbound_click_1 -> outbound_click_count
    -- paid_impression -> paid_impression_count
    -- spend_in_micro_dollar -> spend_micro
    -- targeting_value -> keyword_category
    SELECT 
        "ad_group_id",
        "advertiser_id",
        "campaign_id",
        "date_" AS "performance_date",
        "keyword_id",
        "pin_id",
        "pin_promotion_id",
        "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_1" AS "clickthrough_count",
        "clickthrough_1_gross" AS "clickthrough_count_gross",
        "cpc_in_micro_dollar" AS "cost_per_click_micro",
        "cpm_in_micro_dollar" AS "cost_per_mille_micro",
        "ctr" AS "click_through_rate",
        "ecpc_in_micro_dollar" AS "effective_cost_per_click_micro",
        "ecpm_in_micro_dollar" AS "effective_cost_per_mille_micro",
        "ectr" AS "effective_click_through_rate",
        "engagement_1" AS "engagement_count",
        "impression_1" AS "impression_count",
        "impression_1_gross" AS "impression_count_gross",
        "outbound_click_1" AS "outbound_click_count",
        "paid_impression" AS "paid_impression_count",
        "pin_promotion_name",
        "pin_promotion_status",
        "spend_in_micro_dollar" AS "spend_micro",
        "targeting_type",
        "targeting_value" AS "keyword_category",
        "total_engagement"
    FROM "pinterest_keyword_report_data_projected"
),

"pinterest_keyword_report_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- ad_group_name: The problem is that the ad_group_name column contains a single unusual value that combines a date-time stamp with 'Ad group'. This is not a typical format for an ad group name, which usually consists of a descriptive name related to the ad campaign or target audience. The correct value should be a meaningful ad group name without the date-time prefix. 
    -- keyword_category: The problem is inconsistency in representing cat-related interests. We have 'cat lover', 'cat drawing', and 'cat', which are all related to cats but represented differently. The correct approach would be to standardize these under a single category. Since 'cat lover' is the most frequent among these, we'll use it as the standard representation. 
    SELECT
        "ad_group_id",
        "advertiser_id",
        "campaign_id",
        "performance_date",
        "keyword_id",
        "pin_id",
        "pin_promotion_id",
        CASE
            WHEN "ad_group_name" = '2022-06-07 14:30 | Ad group' THEN 'Ad group'
            ELSE "ad_group_name"
        END AS "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_count",
        "clickthrough_count_gross",
        "cost_per_click_micro",
        "cost_per_mille_micro",
        "click_through_rate",
        "effective_cost_per_click_micro",
        "effective_cost_per_mille_micro",
        "effective_click_through_rate",
        "engagement_count",
        "impression_count",
        "impression_count_gross",
        "outbound_click_count",
        "paid_impression_count",
        "pin_promotion_name",
        "pin_promotion_status",
        "spend_micro",
        "targeting_type",
        CASE
            WHEN "keyword_category" = 'cat drawing' THEN 'cat lover'
            WHEN "keyword_category" = 'cat' THEN 'cat lover'
            ELSE "keyword_category"
        END AS "keyword_category",
        "total_engagement"
    FROM "pinterest_keyword_report_data_projected_renamed"
),

"pinterest_keyword_report_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- ad_group_id: from INT to VARCHAR
    -- advertiser_id: from INT to VARCHAR
    -- campaign_daily_spend_cap: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- campaign_lifetime_spend_cap: from INT to VARCHAR
    -- clickthrough_count: from DECIMAL to INT
    -- clickthrough_count_gross: from DECIMAL to INT
    -- engagement_count: from DECIMAL to INT
    -- keyword_id: from INT to VARCHAR
    -- outbound_click_count: from DECIMAL to INT
    -- performance_date: from VARCHAR to TIMESTAMP
    -- pin_id: from INT to VARCHAR
    -- pin_promotion_id: from INT to VARCHAR
    -- total_engagement: from DECIMAL to VARCHAR
    SELECT
        "ad_group_name",
        "ad_group_status",
        "campaign_name",
        "campaign_status",
        "cost_per_click_micro",
        "cost_per_mille_micro",
        "click_through_rate",
        "effective_cost_per_click_micro",
        "effective_cost_per_mille_micro",
        "effective_click_through_rate",
        "impression_count",
        "impression_count_gross",
        "paid_impression_count",
        "pin_promotion_name",
        "pin_promotion_status",
        "spend_micro",
        "targeting_type",
        "keyword_category",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("campaign_daily_spend_cap" AS VARCHAR) AS "campaign_daily_spend_cap",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("campaign_lifetime_spend_cap" AS VARCHAR) AS "campaign_lifetime_spend_cap",
        CAST("clickthrough_count" AS INT) AS "clickthrough_count",
        CAST("clickthrough_count_gross" AS INT) AS "clickthrough_count_gross",
        CAST("engagement_count" AS INT) AS "engagement_count",
        CAST("keyword_id" AS VARCHAR) AS "keyword_id",
        CAST("outbound_click_count" AS INT) AS "outbound_click_count",
        CAST("performance_date" AS TIMESTAMP) AS "performance_date",
        CAST("pin_id" AS VARCHAR) AS "pin_id",
        CAST("pin_promotion_id" AS VARCHAR) AS "pin_promotion_id",
        CAST("total_engagement" AS VARCHAR) AS "total_engagement"
    FROM "pinterest_keyword_report_data_projected_renamed_cleaned"
),

"pinterest_keyword_report_data_projected_renamed_cleaned_casted_missing_handled" AS (
    -- Handling missing values: There are 9 columns with unacceptable missing values
    -- click_through_rate has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- clickthrough_count has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- clickthrough_count_gross has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- cost_per_click_micro has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- effective_click_through_rate has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- effective_cost_per_click_micro has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- engagement_count has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- outbound_click_count has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- total_engagement has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "ad_group_name",
        "ad_group_status",
        "campaign_name",
        "campaign_status",
        "cost_per_mille_micro",
        "effective_cost_per_mille_micro",
        "impression_count",
        "impression_count_gross",
        "paid_impression_count",
        "pin_promotion_name",
        "pin_promotion_status",
        "spend_micro",
        "targeting_type",
        "keyword_category",
        "ad_group_id",
        "advertiser_id",
        "campaign_daily_spend_cap",
        "campaign_id",
        "campaign_lifetime_spend_cap",
        "keyword_id",
        "performance_date",
        "pin_id",
        "pin_promotion_id"
    FROM "pinterest_keyword_report_data_projected_renamed_cleaned_casted"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_keyword_report_data_projected_renamed_cleaned_casted_missing_handled"

stg_pinterest_keyword_report_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_keyword_report_data
  description: The table is about Pinterest keyword report data. It contains daily
    performance metrics for ad campaigns. Key entities are advertisers, campaigns,
    ad groups, keywords, and pin promotions. Metrics include impressions, spend, CPM,
    and CTR. The data shows how different keywords perform for specific ad campaigns
    and promotions on Pinterest.
  columns:
  - name: ad_group_name
    description: Name of the ad group
    tests:
    - not_null
  - name: ad_group_status
    description: Current status of the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - ENABLED
        - PAUSED
        - REMOVED
        - COMPLETED
        - PENDING
        - DRAFT
        - ARCHIVED
  - name: campaign_name
    description: Name of the campaign
    tests:
    - not_null
  - name: campaign_status
    description: Current status of the campaign
    tests:
    - not_null
    - accepted_values:
        values:
        - DRAFT
        - SCHEDULED
        - ACTIVE
        - PAUSED
        - COMPLETED
        - CANCELLED
        - ARCHIVED
  - name: cost_per_mille_micro
    description: Cost per thousand impressions in micro dollars
    tests:
    - not_null
  - name: effective_cost_per_mille_micro
    description: Effective cost per thousand impressions in micro dollars
    tests:
    - not_null
  - name: impression_count
    description: Number of impressions
    tests:
    - not_null
  - name: impression_count_gross
    description: Gross number of impressions
    tests:
    - not_null
  - name: paid_impression_count
    description: Number of paid impressions
    tests:
    - not_null
  - name: pin_promotion_name
    description: Name of the pin promotion
    tests:
    - not_null
  - name: pin_promotion_status
    description: Current status of the pin promotion
    tests:
    - not_null
    - accepted_values:
        values:
        - PENDING
        - APPROVED
        - REJECTED
        - SUSPENDED
        - COMPLETED
        - CANCELED
  - name: spend_micro
    description: Amount spent in micro dollars
    tests:
    - not_null
  - name: targeting_type
    description: Type of targeting used
    tests:
    - not_null
    - accepted_values:
        values:
        - KEYWORD
        - DEMOGRAPHIC
        - BEHAVIORAL
        - CONTEXTUAL
        - GEOGRAPHIC
        - DEVICE
        - TIME
        - RETARGETING
        - INTEREST
        - LOOKALIKE
        - CUSTOM AUDIENCE
        - PLACEMENT
  - name: keyword_category
    description: Keyword or category targeted by the ad campaign
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: campaign_daily_spend_cap
    description: Daily spending limit for the campaign
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: campaign_lifetime_spend_cap
    description: Lifetime spending limit for the campaign
    tests:
    - not_null
  - name: keyword_id
    description: Unique identifier for the keyword
    tests:
    - not_null
  - name: performance_date
    description: Date of the performance data
    tests:
    - not_null
  - name: pin_id
    description: Unique identifier for the pin
    tests:
    - not_null
  - name: pin_promotion_id
    description: Unique identifier for the pin promotion
    tests:
    - not_null

stg_pinterest_campaign_report_data (first 100 rows)

daily_spend_cap_micro lifetime_spend_cap_micro campaign_name campaign_status total_clicks cpc_micro cpm_micro ctr ecpc_micro ecpm_micro ectr engagements impressions total_impressions paid_impressions spend_micro total_engagements avg_impression_frequency unique_users_reached advertiser_id campaign_id clicks date_ outbound_clicks
0 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 1046 2437506 9.0 1.309136 799 549764253315 626746449918 NaN 2022-06-08 NaN
1 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 1208 2419523 2.0 1.017692 1187 549764253315 626746449918 NaN 2022-06-14 NaN
2 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 1209 2418809 4.0 1.085278 1114 549764253315 626746449918 NaN 2022-06-15 NaN
3 0 25000000 My Cat Is Purrfect COMPLETED NaN NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 223 718556 NaN 1.173684 190 549764253315 626746449918 NaN 2022-06-07 NaN
4 0 25000000 My Cat Is Purrfect COMPLETED 1.0 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 1197 2424901 8.0 1.134597 1055 549764253315 626746449918 1.0 2022-06-10 NaN
5 0 25000000 My Cat Is Purrfect COMPLETED 1.0 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 673 1346372 8.0 0.965567 697 549764253315 626746449918 1.0 2022-06-16 NaN
6 0 25000000 My Cat Is Purrfect COMPLETED 3.0 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1181 2433701 22.0 1.098605 1075 549764253315 626746449918 3.0 2022-06-11 1.0
7 0 25000000 My Cat Is Purrfect COMPLETED 1.0 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1167 2425572 10.0 1.200617 972 549764253315 626746449918 1.0 2022-06-12 1.0
8 0 25000000 My Cat Is Purrfect COMPLETED 1.0 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1038 2436977 16.0 1.098413 945 549764253315 626746449918 1.0 2022-06-09 1.0
9 0 25000000 My Cat Is Purrfect COMPLETED 2.0 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 1185 2434974 15.0 1.070397 1108 549764253315 626746449918 2.0 2022-06-13 2.0

stg_pinterest_campaign_report_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_campaign_report_data_projected" AS (
    -- Projection: Selecting 24 out of 25 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "advertiser_id",
        "campaign_id",
        "date_",
        "campaign_daily_spend_cap",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_1",
        "clickthrough_1_gross",
        "cpc_in_micro_dollar",
        "cpm_in_micro_dollar",
        "ctr",
        "ecpc_in_micro_dollar",
        "ecpm_in_micro_dollar",
        "ectr",
        "engagement_1",
        "impression_1",
        "impression_1_gross",
        "outbound_click_1",
        "paid_impression",
        "spend_in_micro_dollar",
        "total_engagement",
        "total_impression_frequency",
        "total_impression_user"
    FROM "pinterest_campaign_report_data"
),

"pinterest_campaign_report_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- campaign_daily_spend_cap -> daily_spend_cap_micro
    -- campaign_lifetime_spend_cap -> lifetime_spend_cap_micro
    -- clickthrough_1 -> clicks
    -- clickthrough_1_gross -> total_clicks
    -- cpc_in_micro_dollar -> cpc_micro
    -- cpm_in_micro_dollar -> cpm_micro
    -- ecpc_in_micro_dollar -> ecpc_micro
    -- ecpm_in_micro_dollar -> ecpm_micro
    -- engagement_1 -> engagements
    -- impression_1 -> impressions
    -- impression_1_gross -> total_impressions
    -- outbound_click_1 -> outbound_clicks
    -- paid_impression -> paid_impressions
    -- spend_in_micro_dollar -> spend_micro
    -- total_engagement -> total_engagements
    -- total_impression_frequency -> avg_impression_frequency
    -- total_impression_user -> unique_users_reached
    SELECT 
        "advertiser_id",
        "campaign_id",
        "date_",
        "campaign_daily_spend_cap" AS "daily_spend_cap_micro",
        "campaign_lifetime_spend_cap" AS "lifetime_spend_cap_micro",
        "campaign_name",
        "campaign_status",
        "clickthrough_1" AS "clicks",
        "clickthrough_1_gross" AS "total_clicks",
        "cpc_in_micro_dollar" AS "cpc_micro",
        "cpm_in_micro_dollar" AS "cpm_micro",
        "ctr",
        "ecpc_in_micro_dollar" AS "ecpc_micro",
        "ecpm_in_micro_dollar" AS "ecpm_micro",
        "ectr",
        "engagement_1" AS "engagements",
        "impression_1" AS "impressions",
        "impression_1_gross" AS "total_impressions",
        "outbound_click_1" AS "outbound_clicks",
        "paid_impression" AS "paid_impressions",
        "spend_in_micro_dollar" AS "spend_micro",
        "total_engagement" AS "total_engagements",
        "total_impression_frequency" AS "avg_impression_frequency",
        "total_impression_user" AS "unique_users_reached"
    FROM "pinterest_campaign_report_data_projected"
),

"pinterest_campaign_report_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- advertiser_id: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- clicks: from DECIMAL to INT
    -- date_: from VARCHAR to TIMESTAMP
    -- outbound_clicks: from DECIMAL to INT
    SELECT
        "daily_spend_cap_micro",
        "lifetime_spend_cap_micro",
        "campaign_name",
        "campaign_status",
        "total_clicks",
        "cpc_micro",
        "cpm_micro",
        "ctr",
        "ecpc_micro",
        "ecpm_micro",
        "ectr",
        "engagements",
        "impressions",
        "total_impressions",
        "paid_impressions",
        "spend_micro",
        "total_engagements",
        "avg_impression_frequency",
        "unique_users_reached",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("clicks" AS INT) AS "clicks",
        CAST("date_" AS TIMESTAMP) AS "date_",
        CAST("outbound_clicks" AS INT) AS "outbound_clicks"
    FROM "pinterest_campaign_report_data_projected_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_campaign_report_data_projected_renamed_casted"

stg_pinterest_campaign_report_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_campaign_report_data
  description: The table is about a Pinterest advertising campaign named "My Cat Is
    Purrfect". It contains daily performance metrics for this campaign. The data includes
    spend, impressions, clicks, engagement, and various calculated rates like CPM
    and CTR. The campaign has a lifetime spend cap of $25,000,000 and its status is
    "COMPLETED". The table tracks the campaign's performance across different dates
    in June 2022.
  columns:
  - name: daily_spend_cap_micro
    description: Daily spending limit for the campaign in micro-dollars
    tests:
    - not_null
  - name: lifetime_spend_cap_micro
    description: Total spending limit for the campaign in micro-dollars
    tests:
    - not_null
  - name: campaign_name
    description: Name of the advertising campaign
    tests:
    - not_null
  - name: campaign_status
    description: Current status of the campaign
    tests:
    - not_null
    - accepted_values:
        values:
        - DRAFT
        - SCHEDULED
        - ACTIVE
        - PAUSED
        - COMPLETED
        - CANCELLED
        - ARCHIVED
  - name: total_clicks
    description: Total number of clicks including non-billable clicks
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: cpc_micro
    description: Cost per click in micro-dollars
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: cpm_micro
    description: Cost per thousand impressions in micro-dollars
    tests:
    - not_null
  - name: ctr
    description: Click-through rate (clicks divided by impressions)
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: ecpc_micro
    description: Effective cost per click in micro-dollars
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: ecpm_micro
    description: Effective cost per thousand impressions in micro-dollars
    tests:
    - not_null
  - name: ectr
    description: Effective click-through rate
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: engagements
    description: Number of engagements with the ad
    tests:
    - not_null
  - name: impressions
    description: Number of times the ad was displayed
    tests:
    - not_null
  - name: total_impressions
    description: Total number of impressions including non-billable impressions
    tests:
    - not_null
  - name: paid_impressions
    description: Number of paid impressions
    tests:
    - not_null
  - name: spend_micro
    description: Amount spent on the campaign in micro-dollars
    tests:
    - not_null
  - name: total_engagements
    description: Total number of engagements across all metrics
    tests:
    - not_null
  - name: avg_impression_frequency
    description: Average number of times users saw the ad
    tests:
    - not_null
  - name: unique_users_reached
    description: Number of unique users who saw the ad
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: clicks
    description: Number of clicks on the ad
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred in campaign
  - name: date_
    description: Date of the performance metrics
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the date of the performance metrics. For
        this table, each row is for a daily performance of the campaign. date_ is
        unique across rows as there is only one entry per day for the campaign.
  - name: outbound_clicks
    description: Number of clicks leading outside Pinterest
    tests:
    - not_null

stg_pinterest_ad_group_report_data (first 100 rows)

ad_group_name ad_group_status campaign_daily_spend_cap campaign_lifetime_spend_cap campaign_name campaign_status cost_per_click_micro cost_per_thousand_impressions_micro click_through_rate effective_cost_per_click_micro effective_cost_per_thousand_impressions_micro effective_click_through_rate engagement_count impression_count impression_count_gross paid_impression_count spend_micro total_engagement_count average_impression_frequency total_impression_users ad_group_id advertiser_id campaign_id clickthrough_count clickthrough_count_gross outbound_click_count report_date
0 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 223 718556 NaN 1.173684 190 2680072242253 549764253315 626746449918 NaN NaN NaN 2022-06-07
1 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 1046 2437506 9.0 1.309136 799 2680072242253 549764253315 626746449918 NaN NaN NaN 2022-06-08
2 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 1208 2419523 2.0 1.017692 1187 2680072242253 549764253315 626746449918 NaN NaN NaN 2022-06-14
3 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 1209 2418809 4.0 1.085278 1114 2680072242253 549764253315 626746449918 NaN NaN NaN 2022-06-15
4 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 1197 2424901 8.0 1.134597 1055 2680072242253 549764253315 626746449918 1.0 1.0 NaN 2022-06-10
5 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 673 1346372 8.0 0.965567 697 2680072242253 549764253315 626746449918 1.0 1.0 NaN 2022-06-16
6 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1038 2436977 16.0 1.098413 945 2680072242253 549764253315 626746449918 1.0 1.0 1.0 2022-06-09
7 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1181 2433701 22.0 1.098605 1075 2680072242253 549764253315 626746449918 3.0 3.0 1.0 2022-06-11
8 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1167 2425572 10.0 1.200617 972 2680072242253 549764253315 626746449918 1.0 1.0 1.0 2022-06-12
9 Ad group COMPLETED 0 25000000 Cat Campaign: Brand Awareness COMPLETED 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 1185 2434974 15.0 1.070397 1108 2680072242253 549764253315 626746449918 2.0 2.0 2.0 2022-06-13

stg_pinterest_ad_group_report_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_ad_group_report_data_projected" AS (
    -- Projection: Selecting 27 out of 28 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "ad_group_id",
        "advertiser_id",
        "date_",
        "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_id",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_1",
        "clickthrough_1_gross",
        "cpc_in_micro_dollar",
        "cpm_in_micro_dollar",
        "ctr",
        "ecpc_in_micro_dollar",
        "ecpm_in_micro_dollar",
        "ectr",
        "engagement_1",
        "impression_1",
        "impression_1_gross",
        "outbound_click_1",
        "paid_impression",
        "spend_in_micro_dollar",
        "total_engagement",
        "total_impression_frequency",
        "total_impression_user"
    FROM "pinterest_ad_group_report_data"
),

"pinterest_ad_group_report_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- date_ -> report_date
    -- clickthrough_1 -> clickthrough_count
    -- clickthrough_1_gross -> clickthrough_count_gross
    -- cpc_in_micro_dollar -> cost_per_click_micro
    -- cpm_in_micro_dollar -> cost_per_thousand_impressions_micro
    -- ctr -> click_through_rate
    -- ecpc_in_micro_dollar -> effective_cost_per_click_micro
    -- ecpm_in_micro_dollar -> effective_cost_per_thousand_impressions_micro
    -- ectr -> effective_click_through_rate
    -- engagement_1 -> engagement_count
    -- impression_1 -> impression_count
    -- impression_1_gross -> impression_count_gross
    -- outbound_click_1 -> outbound_click_count
    -- paid_impression -> paid_impression_count
    -- spend_in_micro_dollar -> spend_micro
    -- total_engagement -> total_engagement_count
    -- total_impression_frequency -> average_impression_frequency
    -- total_impression_user -> total_impression_users
    SELECT 
        "ad_group_id",
        "advertiser_id",
        "date_" AS "report_date",
        "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_id",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_1" AS "clickthrough_count",
        "clickthrough_1_gross" AS "clickthrough_count_gross",
        "cpc_in_micro_dollar" AS "cost_per_click_micro",
        "cpm_in_micro_dollar" AS "cost_per_thousand_impressions_micro",
        "ctr" AS "click_through_rate",
        "ecpc_in_micro_dollar" AS "effective_cost_per_click_micro",
        "ecpm_in_micro_dollar" AS "effective_cost_per_thousand_impressions_micro",
        "ectr" AS "effective_click_through_rate",
        "engagement_1" AS "engagement_count",
        "impression_1" AS "impression_count",
        "impression_1_gross" AS "impression_count_gross",
        "outbound_click_1" AS "outbound_click_count",
        "paid_impression" AS "paid_impression_count",
        "spend_in_micro_dollar" AS "spend_micro",
        "total_engagement" AS "total_engagement_count",
        "total_impression_frequency" AS "average_impression_frequency",
        "total_impression_user" AS "total_impression_users"
    FROM "pinterest_ad_group_report_data_projected"
),

"pinterest_ad_group_report_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- ad_group_name: The problem is that the ad_group_name column contains a single unusual value that combines a date-time stamp with 'Ad group'. This is not a typical format for an ad group name, which usually consists of a descriptive name related to the ad campaign or target audience. The correct value should be a meaningful ad group name without the date-time prefix. 
    SELECT
        "ad_group_id",
        "advertiser_id",
        "report_date",
        CASE
            WHEN "ad_group_name" = '2022-06-07 14:30 | Ad group' THEN 'Ad group'
            ELSE "ad_group_name"
        END AS "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_id",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "clickthrough_count",
        "clickthrough_count_gross",
        "cost_per_click_micro",
        "cost_per_thousand_impressions_micro",
        "click_through_rate",
        "effective_cost_per_click_micro",
        "effective_cost_per_thousand_impressions_micro",
        "effective_click_through_rate",
        "engagement_count",
        "impression_count",
        "impression_count_gross",
        "outbound_click_count",
        "paid_impression_count",
        "spend_micro",
        "total_engagement_count",
        "average_impression_frequency",
        "total_impression_users"
    FROM "pinterest_ad_group_report_data_projected_renamed"
),

"pinterest_ad_group_report_data_projected_renamed_cleaned_casted" AS (
    -- Column Type Casting: 
    -- ad_group_id: from INT to VARCHAR
    -- advertiser_id: from INT to VARCHAR
    -- campaign_id: from INT to VARCHAR
    -- clickthrough_count: from DECIMAL to INT
    -- clickthrough_count_gross: from DECIMAL to INT
    -- outbound_click_count: from DECIMAL to INT
    -- report_date: from VARCHAR to TIMESTAMP
    SELECT
        "ad_group_name",
        "ad_group_status",
        "campaign_daily_spend_cap",
        "campaign_lifetime_spend_cap",
        "campaign_name",
        "campaign_status",
        "cost_per_click_micro",
        "cost_per_thousand_impressions_micro",
        "click_through_rate",
        "effective_cost_per_click_micro",
        "effective_cost_per_thousand_impressions_micro",
        "effective_click_through_rate",
        "engagement_count",
        "impression_count",
        "impression_count_gross",
        "paid_impression_count",
        "spend_micro",
        "total_engagement_count",
        "average_impression_frequency",
        "total_impression_users",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("clickthrough_count" AS INT) AS "clickthrough_count",
        CAST("clickthrough_count_gross" AS INT) AS "clickthrough_count_gross",
        CAST("outbound_click_count" AS INT) AS "outbound_click_count",
        CAST("report_date" AS TIMESTAMP) AS "report_date"
    FROM "pinterest_ad_group_report_data_projected_renamed_cleaned"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_ad_group_report_data_projected_renamed_cleaned_casted"

stg_pinterest_ad_group_report_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_ad_group_report_data
  description: The table is about Pinterest ad group report data. It contains daily
    metrics for ad groups within campaigns. Details include ad group and campaign
    identifiers, names, statuses, spend caps, and performance metrics like impressions,
    clicks, engagement, and spend. Each row represents one day's data for a specific
    ad group.
  columns:
  - name: ad_group_name
    description: Name of the ad group
    tests:
    - not_null
  - name: ad_group_status
    description: Current status of the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - ENABLED
        - PAUSED
        - REMOVED
        - COMPLETED
        - PENDING
        - DRAFT
        - ARCHIVED
  - name: campaign_daily_spend_cap
    description: Daily spending limit for the campaign
    tests:
    - not_null
  - name: campaign_lifetime_spend_cap
    description: Total spending limit for the campaign
    tests:
    - not_null
  - name: campaign_name
    description: Name of the campaign
    tests:
    - not_null
  - name: campaign_status
    description: Current status of the campaign
    tests:
    - not_null
    - accepted_values:
        values:
        - DRAFT
        - SCHEDULED
        - ACTIVE
        - PAUSED
        - COMPLETED
        - CANCELLED
        - ARCHIVED
  - name: cost_per_click_micro
    description: Cost per click in micro dollars
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: cost_per_thousand_impressions_micro
    description: Cost per thousand impressions in micro dollars
    tests:
    - not_null
  - name: click_through_rate
    description: Click-through rate
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: effective_cost_per_click_micro
    description: Effective cost per click in micro dollars
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: effective_cost_per_thousand_impressions_micro
    description: Effective cost per thousand impressions in micro dollars
    tests:
    - not_null
  - name: effective_click_through_rate
    description: Effective click-through rate
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: engagement_count
    description: Number of engagements
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero engagements.
  - name: impression_count
    description: Number of impressions
    tests:
    - not_null
  - name: impression_count_gross
    description: Gross number of impressions
    tests:
    - not_null
  - name: paid_impression_count
    description: Number of paid impressions
    tests:
    - not_null
  - name: spend_micro
    description: Amount spent in micro dollars
    tests:
    - not_null
  - name: total_engagement_count
    description: Total number of engagements
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero engagements.
  - name: average_impression_frequency
    description: Average impression frequency per user
    tests:
    - not_null
  - name: total_impression_users
    description: Total number of users who saw impressions
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: clickthrough_count
    description: Number of clickthroughs
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: clickthrough_count_gross
    description: Gross number of clickthroughs
    cocoon_meta:
      missing_acceptable: Not applicable when there are zero clicks.
  - name: outbound_click_count
    description: Number of outbound clicks
    tests:
    - not_null
  - name: report_date
    description: Date of the reported metrics
    tests:
    - not_null

stg_pinterest_advertiser_history_data (first 100 rows)

payment_method billing_status account_status country account_currency account_name account_creation_date advertiser_id last_updated_date merchant_id owner_id
0 CASH_MONEY VALID ACTIVE US USD That Kitty Cat Company 2022-06-07 14:17:13 549764253315 2022-06-07 14:43:17 None 1111111

stg_pinterest_advertiser_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_advertiser_history_data_projected" AS (
    -- Projection: Selecting 13 out of 14 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "updated_time",
        "billing_profile_status",
        "billing_type",
        "country",
        "created_time",
        "currency",
        "merchant_id",
        "name",
        "owner_user_id",
        "status",
        "owner_username",
        "permissions"
    FROM "pinterest_advertiser_history_data"
),

"pinterest_advertiser_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> advertiser_id
    -- updated_time -> last_updated_date
    -- billing_profile_status -> billing_status
    -- billing_type -> payment_method
    -- created_time -> account_creation_date
    -- currency -> account_currency
    -- name -> account_name
    -- owner_user_id -> owner_id
    -- status -> account_status
    -- permissions -> account_permissions
    SELECT 
        "id" AS "advertiser_id",
        "updated_time" AS "last_updated_date",
        "billing_profile_status" AS "billing_status",
        "billing_type" AS "payment_method",
        "country",
        "created_time" AS "account_creation_date",
        "currency" AS "account_currency",
        "merchant_id",
        "name" AS "account_name",
        "owner_user_id" AS "owner_id",
        "status" AS "account_status",
        "owner_username",
        "permissions" AS "account_permissions"
    FROM "pinterest_advertiser_history_data_projected"
),

"pinterest_advertiser_history_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- owner_username: The problem is that 'username' is a generic placeholder value and not a real username. In a real dataset, this column should contain actual usernames of the owners. Since we don't have any real usernames to map to, and a generic placeholder is not meaningful data, we should map this to an empty string. 
    -- account_permissions: The problem is that 'string' is being used as a placeholder value for the account_permissions column, which is not a meaningful representation of actual account permissions. This suggests that either the real permission data is missing or was not properly populated. In a real-world scenario, account permissions would typically be specific descriptors like 'read', 'write', 'admin', or combinations of these. Without knowing the intended permission structure for this system, we can't map 'string' to a correct value. The best approach is to map it to an empty string to indicate missing data. 
    SELECT
        "advertiser_id",
        "last_updated_date",
        "billing_status",
        "payment_method",
        "country",
        "account_creation_date",
        "account_currency",
        "merchant_id",
        "account_name",
        "owner_id",
        "account_status",
        CASE
            WHEN "owner_username" = 'username' THEN ''
            ELSE "owner_username"
        END AS "owner_username",
        CASE
            WHEN "account_permissions" = 'string' THEN ''
            ELSE "account_permissions"
        END AS "account_permissions"
    FROM "pinterest_advertiser_history_data_projected_renamed"
),

"pinterest_advertiser_history_data_projected_renamed_cleaned_null" AS (
    -- NULL Imputation: Impute Null to Disguised Missing Values
    -- owner_username: ['']
    -- account_permissions: ['']
    SELECT 
        CASE
            WHEN "owner_username" = '' THEN NULL
            ELSE "owner_username"
        END AS "owner_username",
        CASE
            WHEN "account_permissions" = '' THEN NULL
            ELSE "account_permissions"
        END AS "account_permissions",
        "owner_id",
        "payment_method",
        "advertiser_id",
        "billing_status",
        "account_status",
        "country",
        "account_creation_date",
        "account_currency",
        "merchant_id",
        "account_name",
        "last_updated_date"
    FROM "pinterest_advertiser_history_data_projected_renamed_cleaned"
),

"pinterest_advertiser_history_data_projected_renamed_cleaned_null_casted" AS (
    -- Column Type Casting: 
    -- account_creation_date: from VARCHAR to TIMESTAMP
    -- advertiser_id: from INT to VARCHAR
    -- last_updated_date: from VARCHAR to TIMESTAMP
    -- merchant_id: from DECIMAL to VARCHAR
    -- owner_id: from INT to VARCHAR
    SELECT
        "owner_username",
        "account_permissions",
        "payment_method",
        "billing_status",
        "account_status",
        "country",
        "account_currency",
        "account_name",
        CAST("account_creation_date" AS TIMESTAMP) AS "account_creation_date",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("last_updated_date" AS TIMESTAMP) AS "last_updated_date",
        CAST("merchant_id" AS VARCHAR) AS "merchant_id",
        CAST("owner_id" AS VARCHAR) AS "owner_id"
    FROM "pinterest_advertiser_history_data_projected_renamed_cleaned_null"
),

"pinterest_advertiser_history_data_projected_renamed_cleaned_null_casted_missing_handled" AS (
    -- Handling missing values: There are 2 columns with unacceptable missing values
    -- account_permissions has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- owner_username has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "payment_method",
        "billing_status",
        "account_status",
        "country",
        "account_currency",
        "account_name",
        "account_creation_date",
        "advertiser_id",
        "last_updated_date",
        "merchant_id",
        "owner_id"
    FROM "pinterest_advertiser_history_data_projected_renamed_cleaned_null_casted"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_advertiser_history_data_projected_renamed_cleaned_null_casted_missing_handled"

stg_pinterest_advertiser_history_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_advertiser_history_data
  description: The table is about Pinterest advertiser accounts. It contains details
    such as account ID, billing information, country, creation date, currency, merchant
    ID, account name, owner details, status, and permissions. This data represents
    the history and current state of advertiser accounts on the Pinterest platform.
  columns:
  - name: payment_method
    description: Method of billing for the advertiser account
    tests:
    - not_null
    - accepted_values:
        values:
        - CASH_MONEY
        - CREDIT_CARD
        - BANK_TRANSFER
        - PAYPAL
        - CHECK
        - DIRECT_DEBIT
        - INVOICE
        - PREPAID_BALANCE
        - WIRE_TRANSFER
        - ACH
        - CRYPTOCURRENCY
  - name: billing_status
    description: Indicates the validity of the billing profile
    tests:
    - not_null
    - accepted_values:
        values:
        - VALID
        - INVALID
        - PENDING
  - name: account_status
    description: Current operational status of the account
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - INACTIVE
        - SUSPENDED
        - CLOSED
        - PENDING
        - LOCKED
        - RESTRICTED
        - DORMANT
  - name: country
    description: Country where the advertiser account is registered
    tests:
    - not_null
  - name: account_currency
    description: Currency used for transactions in the account
    tests:
    - not_null
  - name: account_name
    description: Name of the advertiser account
    tests:
    - not_null
  - name: account_creation_date
    description: Timestamp when the account was created
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser account
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for the advertiser account. For
        this table, each row is for a unique advertiser account. Advertiser ID is
        designed to be unique across rows, ensuring each account has a distinct identifier.
  - name: last_updated_date
    description: Timestamp of the last account update
    tests:
    - not_null
  - name: merchant_id
    description: Identifier for the merchant, if applicable
    cocoon_meta:
      missing_acceptable: Not applicable for non-merchant advertisers.
  - name: owner_id
    description: Unique identifier of the account owner
    tests:
    - not_null

stg_pinterest_advertiser_report_data (first 100 rows)

cost_per_click_micro cost_per_mille_micro click_through_rate effective_cost_per_click_micro effective_cost_per_mille_micro effective_click_through_rate engagement_count impression_count total_impression_count paid_impression_count total_spend_micro total_engagement_count average_impression_frequency unique_user_reach advertiser_id click_count outbound_click_count report_date total_click_count
0 NaN 2000669.148 NaN NaN 2000669.148 NaN 4.0 1209 1345 1209 2418809 4.0 1.085278 1114 549764253315 NaN NaN 2022-06-15 NaN
1 NaN 3222224.215 NaN NaN 3222224.215 NaN NaN 223 267 223 718556 NaN 1.173684 190 549764253315 NaN NaN 2022-06-07 NaN
2 NaN 2330311.663 NaN NaN 2330311.663 NaN 9.0 1046 1341 1046 2437506 9.0 1.309136 799 549764253315 NaN NaN 2022-06-08 NaN
3 NaN 2002916.391 NaN NaN 2002916.391 NaN 2.0 1208 1401 1208 2419523 2.0 1.017692 1187 549764253315 NaN NaN 2022-06-14 NaN
4 2.424901e+06 2025815.372 0.000835 2.424901e+06 2025815.372 0.000835 8.0 1197 1417 1197 2424901 8.0 1.134597 1055 549764253315 1.0 NaN 2022-06-10 1.0
5 1.346372e+06 2000552.749 0.001486 1.346372e+06 2000552.749 0.001486 8.0 673 712 673 1346372 8.0 0.965567 697 549764253315 1.0 NaN 2022-06-16 1.0
6 8.112337e+05 2060712.108 0.002540 8.112337e+05 2060712.108 0.002540 22.0 1181 1369 1181 2433701 22.0 1.098605 1075 549764253315 3.0 1.0 2022-06-11 3.0
7 2.425572e+06 2078467.866 0.000857 2.425572e+06 2078467.866 0.000857 10.0 1167 1370 1167 2425572 10.0 1.200617 972 549764253315 1.0 1.0 2022-06-12 1.0
8 2.436977e+06 2347762.042 0.000963 2.436977e+06 2347762.042 0.000963 16.0 1038 1262 1038 2436977 16.0 1.098413 945 549764253315 1.0 1.0 2022-06-09 1.0
9 1.217487e+06 2053097.808 0.001686 1.217487e+06 2053097.808 0.001686 15.0 1186 1417 1185 2434974 15.0 1.070397 1108 549764253315 2.0 2.0 2022-06-13 2.0

stg_pinterest_advertiser_report_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_advertiser_report_data_projected" AS (
    -- Projection: Selecting 19 out of 20 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "advertiser_id",
        "date_",
        "clickthrough_1",
        "clickthrough_1_gross",
        "cpc_in_micro_dollar",
        "cpm_in_micro_dollar",
        "ctr",
        "ecpc_in_micro_dollar",
        "ecpm_in_micro_dollar",
        "ectr",
        "engagement_1",
        "impression_1",
        "impression_1_gross",
        "outbound_click_1",
        "paid_impression",
        "spend_in_micro_dollar",
        "total_engagement",
        "total_impression_frequency",
        "total_impression_user"
    FROM "pinterest_advertiser_report_data"
),

"pinterest_advertiser_report_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- date_ -> report_date
    -- clickthrough_1 -> click_count
    -- clickthrough_1_gross -> total_click_count
    -- cpc_in_micro_dollar -> cost_per_click_micro
    -- cpm_in_micro_dollar -> cost_per_mille_micro
    -- ctr -> click_through_rate
    -- ecpc_in_micro_dollar -> effective_cost_per_click_micro
    -- ecpm_in_micro_dollar -> effective_cost_per_mille_micro
    -- ectr -> effective_click_through_rate
    -- engagement_1 -> engagement_count
    -- impression_1 -> impression_count
    -- impression_1_gross -> total_impression_count
    -- outbound_click_1 -> outbound_click_count
    -- paid_impression -> paid_impression_count
    -- spend_in_micro_dollar -> total_spend_micro
    -- total_engagement -> total_engagement_count
    -- total_impression_frequency -> average_impression_frequency
    -- total_impression_user -> unique_user_reach
    SELECT 
        "advertiser_id",
        "date_" AS "report_date",
        "clickthrough_1" AS "click_count",
        "clickthrough_1_gross" AS "total_click_count",
        "cpc_in_micro_dollar" AS "cost_per_click_micro",
        "cpm_in_micro_dollar" AS "cost_per_mille_micro",
        "ctr" AS "click_through_rate",
        "ecpc_in_micro_dollar" AS "effective_cost_per_click_micro",
        "ecpm_in_micro_dollar" AS "effective_cost_per_mille_micro",
        "ectr" AS "effective_click_through_rate",
        "engagement_1" AS "engagement_count",
        "impression_1" AS "impression_count",
        "impression_1_gross" AS "total_impression_count",
        "outbound_click_1" AS "outbound_click_count",
        "paid_impression" AS "paid_impression_count",
        "spend_in_micro_dollar" AS "total_spend_micro",
        "total_engagement" AS "total_engagement_count",
        "total_impression_frequency" AS "average_impression_frequency",
        "total_impression_user" AS "unique_user_reach"
    FROM "pinterest_advertiser_report_data_projected"
),

"pinterest_advertiser_report_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- advertiser_id: from INT to VARCHAR
    -- click_count: from DECIMAL to INT
    -- outbound_click_count: from DECIMAL to INT
    -- report_date: from VARCHAR to TIMESTAMP
    -- total_click_count: from DECIMAL to INT
    SELECT
        "cost_per_click_micro",
        "cost_per_mille_micro",
        "click_through_rate",
        "effective_cost_per_click_micro",
        "effective_cost_per_mille_micro",
        "effective_click_through_rate",
        "engagement_count",
        "impression_count",
        "total_impression_count",
        "paid_impression_count",
        "total_spend_micro",
        "total_engagement_count",
        "average_impression_frequency",
        "unique_user_reach",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("click_count" AS INT) AS "click_count",
        CAST("outbound_click_count" AS INT) AS "outbound_click_count",
        CAST("report_date" AS TIMESTAMP) AS "report_date",
        CAST("total_click_count" AS INT) AS "total_click_count"
    FROM "pinterest_advertiser_report_data_projected_renamed"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_advertiser_report_data_projected_renamed_casted"

stg_pinterest_advertiser_report_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_advertiser_report_data
  description: The table is about Pinterest advertiser report data. It contains daily
    metrics for a specific advertiser, identified by advertiser_id. The data includes
    impression counts, engagement rates, click-through rates, and cost metrics like
    CPC and CPM. It also shows spend amounts and frequency of impressions per user,
    providing a comprehensive view of the advertiser's campaign performance on Pinterest.
  columns:
  - name: cost_per_click_micro
    description: Cost per click in millionths of a dollar
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.
  - name: cost_per_mille_micro
    description: Cost per thousand impressions in millionths of a dollar
    tests:
    - not_null
  - name: click_through_rate
    description: Click-through rate
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.
  - name: effective_cost_per_click_micro
    description: Effective cost per click in millionths of a dollar
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.
  - name: effective_cost_per_mille_micro
    description: Effective cost per thousand impressions in millionths of a dollar
    tests:
    - not_null
  - name: effective_click_through_rate
    description: Effective click-through rate
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.
  - name: engagement_count
    description: Number of engagements with the ad
    tests:
    - not_null
  - name: impression_count
    description: Number of times the ad was displayed
    tests:
    - not_null
  - name: total_impression_count
    description: Total number of impressions including repeat views
    tests:
    - not_null
  - name: paid_impression_count
    description: Number of paid impressions
    tests:
    - not_null
  - name: total_spend_micro
    description: Total amount spent in millionths of a dollar
    tests:
    - not_null
  - name: total_engagement_count
    description: Total number of engagements
    tests:
    - not_null
  - name: average_impression_frequency
    description: Average number of times users saw the ad
    tests:
    - not_null
  - name: unique_user_reach
    description: Number of unique users who saw the ad
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: click_count
    description: Number of clicks on the ad
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.
  - name: outbound_click_count
    description: Number of clicks leading outside Pinterest
    tests:
    - not_null
  - name: report_date
    description: Date of the reported metrics
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the date of the reported metrics. For this
        table, each row is a daily report for a specific advertiser. Assuming there's
        only one report per day per advertiser, this column combined with the advertiser_id
        could form a composite candidate key.
  - name: total_click_count
    description: Total number of clicks including repeat clicks
    cocoon_meta:
      missing_acceptable: Not applicable when no clicks occurred.

stg_pinterest_campaign_history_data (first 100 rows)

is_automated has_flexible_daily_budgets campaign_status default_ad_group_budget_micro has_budget_optimization advertiser_id campaign_creation_time campaign_id
0 True True ACTIVE 134 True 151515151 2020-03-26 08:59:57+00:00 626741793779

stg_pinterest_campaign_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_campaign_history_data_projected" AS (
    -- Projection: Selecting 9 out of 10 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "id",
        "created_time",
        "name",
        "status",
        "advertiser_id",
        "default_ad_group_budget_in_micro_currency",
        "is_automated_campaign",
        "is_campaign_budget_optimization",
        "is_flexible_daily_budgets"
    FROM "pinterest_campaign_history_data"
),

"pinterest_campaign_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- id -> campaign_id
    -- created_time -> campaign_creation_time
    -- name -> campaign_name
    -- status -> campaign_status
    -- default_ad_group_budget_in_micro_currency -> default_ad_group_budget_micro
    -- is_automated_campaign -> is_automated
    -- is_campaign_budget_optimization -> has_budget_optimization
    -- is_flexible_daily_budgets -> has_flexible_daily_budgets
    SELECT 
        "id" AS "campaign_id",
        "created_time" AS "campaign_creation_time",
        "name" AS "campaign_name",
        "status" AS "campaign_status",
        "advertiser_id",
        "default_ad_group_budget_in_micro_currency" AS "default_ad_group_budget_micro",
        "is_automated_campaign" AS "is_automated",
        "is_campaign_budget_optimization" AS "has_budget_optimization",
        "is_flexible_daily_budgets" AS "has_flexible_daily_budgets"
    FROM "pinterest_campaign_history_data_projected"
),

"pinterest_campaign_history_data_projected_renamed_cleaned" AS (
    -- Clean unusual string values: 
    -- campaign_name: The problem is that the campaign_name column contains a single hexadecimal string value ('19e757f946601de26307d8182635b716') which appears to be a hash or unique identifier rather than a descriptive campaign name. This is unusual for a campaign name column, which typically contains human-readable text describing the campaign. The correct value should be a meaningful campaign name, but since we don't have that information, we'll map it to an empty string to indicate missing data. 
    SELECT
        "campaign_id",
        "campaign_creation_time",
        CASE
            WHEN "campaign_name" = '19e757f946601de26307d8182635b716' THEN ''
            ELSE "campaign_name"
        END AS "campaign_name",
        "campaign_status",
        "advertiser_id",
        "default_ad_group_budget_micro",
        "is_automated",
        "has_budget_optimization",
        "has_flexible_daily_budgets"
    FROM "pinterest_campaign_history_data_projected_renamed"
),

"pinterest_campaign_history_data_projected_renamed_cleaned_null" AS (
    -- NULL Imputation: Impute Null to Disguised Missing Values
    -- campaign_name: ['']
    SELECT 
        CASE
            WHEN "campaign_name" = '' THEN NULL
            ELSE "campaign_name"
        END AS "campaign_name",
        "campaign_id",
        "is_automated",
        "has_flexible_daily_budgets",
        "campaign_status",
        "default_ad_group_budget_micro",
        "advertiser_id",
        "has_budget_optimization",
        "campaign_creation_time"
    FROM "pinterest_campaign_history_data_projected_renamed_cleaned"
),

"pinterest_campaign_history_data_projected_renamed_cleaned_null_casted" AS (
    -- Column Type Casting: 
    -- advertiser_id: from INT to VARCHAR
    -- campaign_creation_time: from VARCHAR to TIMESTAMP
    -- campaign_id: from INT to VARCHAR
    SELECT
        "campaign_name",
        "is_automated",
        "has_flexible_daily_budgets",
        "campaign_status",
        "default_ad_group_budget_micro",
        "has_budget_optimization",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        strptime("campaign_creation_time", '%Y-%m-%d %H:%M:%S.%f %z') AS "campaign_creation_time",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id"
    FROM "pinterest_campaign_history_data_projected_renamed_cleaned_null"
),

"pinterest_campaign_history_data_projected_renamed_cleaned_null_casted_missing_handled" AS (
    -- Handling missing values: There are 1 columns with unacceptable missing values
    -- campaign_name has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "is_automated",
        "has_flexible_daily_budgets",
        "campaign_status",
        "default_ad_group_budget_micro",
        "has_budget_optimization",
        "advertiser_id",
        "campaign_creation_time",
        "campaign_id"
    FROM "pinterest_campaign_history_data_projected_renamed_cleaned_null_casted"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_campaign_history_data_projected_renamed_cleaned_null_casted_missing_handled"

stg_pinterest_campaign_history_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_campaign_history_data
  description: The table is about Pinterest advertising campaigns. It includes details
    such as campaign ID, creation time, name, status, advertiser ID, budget information,
    and campaign settings. Each row represents a unique campaign with its associated
    attributes. The table tracks campaign characteristics like automated status, budget
    optimization, and flexible daily budgets.
  columns:
  - name: is_automated
    description: Indicates if the campaign is automated
    tests:
    - not_null
  - name: has_flexible_daily_budgets
    description: Indicates if flexible daily budgets are enabled
    tests:
    - not_null
  - name: campaign_status
    description: Current status of the campaign
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - PAUSED
        - COMPLETED
        - SCHEDULED
        - DRAFT
        - CANCELLED
        - ARCHIVED
  - name: default_ad_group_budget_micro
    description: Default budget for ad groups in micro currency
    tests:
    - not_null
  - name: has_budget_optimization
    description: Indicates if budget optimization is enabled
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser
    tests:
    - not_null
  - name: campaign_creation_time
    description: Timestamp when the campaign was created
    tests:
    - not_null
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column represents the unique identifier for the campaign. For
        this table, each row represents a unique campaign. campaign_id is unique across
        rows as it is designed to uniquely identify each campaign.

stg_pinterest_keyword_history_data (first 100 rows)

fivetran_sync_id is_archived match_type parent_type keyword_text ad_group_id keyword_id
0 EzxgxB9EE6a6AMma/sqx0ZB4pPU= False BROAD AD_GROUP development 2680072242253 2886843206594
1 wYse+Xtf2L/SnzThOMnxccXJaM4= False BROAD AD_GROUP pasta 2680072242253 2886843206590
2 DauS5IYbqd9myiE2Sf48/gxdYtk= False BROAD AD_GROUP gaming 2680072242253 2886843206587
3 dnYod6xOMc/p/1/vRVBmtHc9MOE= False BROAD AD_GROUP game animals 2680072242253 2886843206595
4 e7sEbGLUh9M3kDrqPQRjk4VSEiU= False BROAD AD_GROUP cat 2680072242253 2886843206586
5 WKo7cli6AW25q84txWkj0ElbNgc= False BROAD AD_GROUP you 2680072242253 2886843206593
6 Rm9dXZR1BJWn52udNn+s1+hKXoc= False BROAD AD_GROUP are 2680072242253 2886843206589
7 vRfN8m9pY6IRUVV8H7N9lQQaEYU= False BROAD AD_GROUP curious 2680072242253 2886843206591
8 3wtluSTMp046Wxz/zVO0oh+Ldh4= False BROAD AD_GROUP aren't 2680072242253 2886843206592
9 bVbQarPqKGBt68E4yzjc6GV/+tI= False BROAD AD_GROUP you 2680072242253 2886843206588

stg_pinterest_keyword_history_data.sql (clean the table)

-- COCOON BLOCK START: PLEASE DO NOT MODIFY THIS BLOCK FOR SELF-MAINTENANCE
WITH 
"pinterest_keyword_history_data_projected" AS (
    -- Projection: Selecting 10 out of 11 columns
    -- Columns projected out: ['_fivetran_synced']
    SELECT 
        "_fivetran_id",
        "ad_group_id",
        "advertiser_id",
        "archived",
        "bid",
        "campaign_id",
        "id",
        "match_type",
        "parent_type",
        "value_"
    FROM "pinterest_keyword_history_data"
),

"pinterest_keyword_history_data_projected_renamed" AS (
    -- Rename: Renaming columns
    -- _fivetran_id -> fivetran_sync_id
    -- archived -> is_archived
    -- bid -> bid_amount
    -- id -> keyword_id
    -- value_ -> keyword_text
    SELECT 
        "_fivetran_id" AS "fivetran_sync_id",
        "ad_group_id",
        "advertiser_id",
        "archived" AS "is_archived",
        "bid" AS "bid_amount",
        "campaign_id",
        "id" AS "keyword_id",
        "match_type",
        "parent_type",
        "value_" AS "keyword_text"
    FROM "pinterest_keyword_history_data_projected"
),

"pinterest_keyword_history_data_projected_renamed_casted" AS (
    -- Column Type Casting: 
    -- ad_group_id: from INT to VARCHAR
    -- advertiser_id: from DECIMAL to VARCHAR
    -- bid_amount: from DECIMAL to VARCHAR
    -- campaign_id: from DECIMAL to VARCHAR
    -- keyword_id: from INT to VARCHAR
    SELECT
        "fivetran_sync_id",
        "is_archived",
        "match_type",
        "parent_type",
        "keyword_text",
        CAST("ad_group_id" AS VARCHAR) AS "ad_group_id",
        CAST("advertiser_id" AS VARCHAR) AS "advertiser_id",
        CAST("bid_amount" AS VARCHAR) AS "bid_amount",
        CAST("campaign_id" AS VARCHAR) AS "campaign_id",
        CAST("keyword_id" AS VARCHAR) AS "keyword_id"
    FROM "pinterest_keyword_history_data_projected_renamed"
),

"pinterest_keyword_history_data_projected_renamed_casted_missing_handled" AS (
    -- Handling missing values: There are 3 columns with unacceptable missing values
    -- advertiser_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- bid_amount has 100.0 percent missing. Strategy: 🗑️ Drop Column
    -- campaign_id has 100.0 percent missing. Strategy: 🗑️ Drop Column
    SELECT
        "fivetran_sync_id",
        "is_archived",
        "match_type",
        "parent_type",
        "keyword_text",
        "ad_group_id",
        "keyword_id"
    FROM "pinterest_keyword_history_data_projected_renamed_casted"
)

-- COCOON BLOCK END
SELECT * FROM "pinterest_keyword_history_data_projected_renamed_casted_missing_handled"

stg_pinterest_keyword_history_data.yml (Document the table)

version: 2
models:
- name: stg_pinterest_keyword_history_data
  description: The table is about Pinterest keyword history data. It contains details
    of keywords used in ad campaigns, including the ad group ID, campaign ID, keyword
    value, match type, and whether it's archived. Each keyword is identified by a
    unique ID and associated with a specific ad group. The data appears to be used
    for tracking and managing keywords in Pinterest advertising campaigns.
  columns:
  - name: fivetran_sync_id
    description: Unique identifier for Fivetran data sync
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for Fivetran data sync. For this
        table, each row represents a keyword in an ad campaign. The fivetran_sync_id
        appears to be unique across rows in the given sample.
  - name: is_archived
    description: Indicates if the keyword is archived
    tests:
    - not_null
  - name: match_type
    description: Type of keyword match
    tests:
    - not_null
    - accepted_values:
        values:
        - BROAD
        - PHRASE
        - EXACT
        - BROAD_MATCH_MODIFIER
  - name: parent_type
    description: Type of parent entity
    tests:
    - not_null
    - accepted_values:
        values:
        - AD_GROUP
        - CAMPAIGN
        - ACCOUNT
        - CUSTOMER
        - MANAGER_ACCOUNT
  - name: keyword_text
    description: The actual keyword text
    tests:
    - not_null
  - name: ad_group_id
    description: Identifier for the ad group
    tests:
    - not_null
  - name: keyword_id
    description: Unique identifier for the keyword
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: This column is a unique identifier for each keyword. For this table,
        each row represents a unique keyword, and the keyword_id is likely to be unique
        across all rows.
Some tables log change events, which may be redundant to query. Instead, we take a snapshot of the latest.

snapshot_pinterest_ad_group_history_data (first 100 rows)

ad_group_name ad_group_status pacing_delivery_type placement_group summary_status ad_account_id ad_group_id campaign_id creation_timestamp start_timestamp
0 22a5457e096095c4e295a3c921db864c ACTIVE STANDARD SEARCH RUNNING 151515151 2680065434868 626741793779 2020-03-26 09:36:43+00:00 2020-03-26 09:36:00
1 304b2dc4ed50ff5b6d714b810d8b50cf ACTIVE STANDARD OTHER RUNNING 151515151 2680065434881 626741793779 2020-03-26 09:37:17+00:00 2020-03-26 09:36:00
2 5c7cdb607c2e540062914e276045d4d5 ACTIVE STANDARD BROWSE RUNNING 151515151 2680065434863 626741793779 2020-03-26 09:35:49+00:00 2020-03-26 09:34:00
3 9f8de0662581357b8af505197ad8145d ACTIVE STANDARD ALL RUNNING 151515151 2680065434898 626741793779 2020-03-26 09:38:46+00:00 2020-03-26 09:37:00

snapshot_pinterest_ad_group_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "ad_group_id"
-- Effective date columns are "end_timestamp"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "ad_group_name",
    "ad_group_status",
    "pacing_delivery_type",
    "placement_group",
    "summary_status",
    "ad_account_id",
    "ad_group_id",
    "campaign_id",
    "creation_timestamp",
    "start_timestamp"
FROM (
     SELECT 
            "ad_group_name",
            "ad_group_status",
            "pacing_delivery_type",
            "placement_group",
            "summary_status",
            "ad_account_id",
            "ad_group_id",
            "campaign_id",
            "creation_timestamp",
            "start_timestamp",
            ROW_NUMBER() OVER (
                PARTITION BY "ad_group_id" 
                ORDER BY "end_timestamp" 
            DESC) AS "cocoon_rn"
    FROM "stg_pinterest_ad_group_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_pinterest_ad_group_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_pinterest_ad_group_history_data
  description: The table is about current Pinterest ad group data. It tracks the most
    recent version of each ad group, including its name, status, pacing delivery type,
    placement group, summary status, and associated IDs. Each row represents a unique
    ad group with its latest attributes and settings. The table excludes historical
    versions and timestamp information.
  columns:
  - name: ad_group_name
    description: Name or identifier of the ad group
    tests:
    - not_null
  - name: ad_group_status
    description: Current status of the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - PAUSED
        - REMOVED
        - PENDING
        - DELETED
  - name: pacing_delivery_type
    description: Type of pacing delivery for the ad group
    tests:
    - not_null
    - accepted_values:
        values:
        - STANDARD
        - ACCELERATED
        - EVEN
  - name: placement_group
    description: Group where the ad is placed
    tests:
    - not_null
    - accepted_values:
        values:
        - ALL
        - BROWSE
        - OTHER
        - SEARCH
        - HOME
        - FEED
        - PROFILE
        - VIDEO
        - STORIES
        - MARKETPLACE
        - EVENTS
        - GROUPS
        - MESSENGER
        - NEWS
        - APPS
        - GAMES
  - name: summary_status
    description: Summary of the ad group's overall status
    tests:
    - not_null
    - accepted_values:
        values:
        - RUNNING
        - PAUSED
        - REMOVED
        - ENABLED
        - DISABLED
        - PENDING
        - ENDED
        - ARCHIVED
  - name: ad_account_id
    description: Unique identifier for the ad account
    tests:
    - not_null
  - name: ad_group_id
    description: Unique identifier for the ad group
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: campaign_id
    description: Unique identifier for the campaign
    tests:
    - not_null
  - name: creation_timestamp
    description: Timestamp when the ad group was created
    tests:
    - not_null
  - name: start_timestamp
    description: Timestamp when the ad group starts
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_pinterest_ad_group_history_data

snapshot_pinterest_advertiser_history_data (first 100 rows)

payment_method billing_status account_status country account_currency account_name account_creation_date advertiser_id merchant_id owner_id
0 CASH_MONEY VALID ACTIVE US USD That Kitty Cat Company 2022-06-07 14:17:13 549764253315 None 1111111

snapshot_pinterest_advertiser_history_data.sql (clean the table)

-- Slowly Changing Dimension: Dimension keys are "advertiser_id"
-- Effective date columns are "last_updated_date"
-- We will create Type 1 SCD (latest snapshot)
SELECT 
    "payment_method",
    "billing_status",
    "account_status",
    "country",
    "account_currency",
    "account_name",
    "account_creation_date",
    "advertiser_id",
    "merchant_id",
    "owner_id"
FROM (
     SELECT 
            "payment_method",
            "billing_status",
            "account_status",
            "country",
            "account_currency",
            "account_name",
            "account_creation_date",
            "advertiser_id",
            "merchant_id",
            "owner_id",
            ROW_NUMBER() OVER (
                PARTITION BY "advertiser_id" 
                ORDER BY "last_updated_date" 
            DESC) AS "cocoon_rn"
    FROM "stg_pinterest_advertiser_history_data"
) ranked
WHERE "cocoon_rn" = 1

snapshot_pinterest_advertiser_history_data.yml (Document the table)

version: 2
models:
- name: snapshot_pinterest_advertiser_history_data
  description: The table is about current Pinterest advertiser accounts. It tracks
    the most recent version of each advertiser's account details. It includes information
    such as payment method, billing status, account status, country, currency, account
    name, creation date, advertiser ID, merchant ID, and owner ID. This snapshot represents
    the latest state of active advertiser accounts on the Pinterest platform.
  columns:
  - name: payment_method
    description: Method of billing for the advertiser account
    tests:
    - not_null
    - accepted_values:
        values:
        - CASH_MONEY
        - CREDIT_CARD
        - BANK_TRANSFER
        - PAYPAL
        - CHECK
        - DIRECT_DEBIT
        - INVOICE
        - PREPAID_BALANCE
        - WIRE_TRANSFER
        - ACH
        - CRYPTOCURRENCY
  - name: billing_status
    description: Indicates the validity of the billing profile
    tests:
    - not_null
    - accepted_values:
        values:
        - VALID
        - INVALID
        - PENDING
  - name: account_status
    description: Current operational status of the account
    tests:
    - not_null
    - accepted_values:
        values:
        - ACTIVE
        - INACTIVE
        - SUSPENDED
        - CLOSED
        - PENDING
        - LOCKED
        - RESTRICTED
        - DORMANT
  - name: country
    description: Country where the advertiser account is registered
    tests:
    - not_null
  - name: account_currency
    description: Currency used for transactions in the account
    tests:
    - not_null
  - name: account_name
    description: Name of the advertiser account
    tests:
    - not_null
  - name: account_creation_date
    description: Timestamp when the account was created
    tests:
    - not_null
  - name: advertiser_id
    description: Unique identifier for the advertiser account
    tests:
    - not_null
    - unique
    cocoon_meta:
      uniqueness: Unique dimension key, derived from the slowly changing dimension
  - name: merchant_id
    description: Identifier for the merchant, if applicable
    cocoon_meta:
      missing_acceptable: Not applicable for non-merchant advertisers.
  - name: owner_id
    description: Unique identifier of the account owner
    tests:
    - not_null
cocoon_meta:
  scd_base_table: stg_pinterest_advertiser_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_pinterest_advertiser_history_data snapshot_pinterest_advertiser_history_data stg_pinterest_campaign_report_data stg_pinterest_campaign_report_data stg_pinterest_campaign_report_data->snapshot_pinterest_advertiser_history_data stg_pinterest_campaign_history_data stg_pinterest_campaign_history_data stg_pinterest_campaign_report_data->stg_pinterest_campaign_history_data snapshot_pinterest_ad_group_history_data snapshot_pinterest_ad_group_history_data snapshot_pinterest_ad_group_history_data->stg_pinterest_campaign_history_data stg_pinterest_ad_group_report_data stg_pinterest_ad_group_report_data stg_pinterest_ad_group_report_data->snapshot_pinterest_advertiser_history_data stg_pinterest_ad_group_report_data->snapshot_pinterest_ad_group_history_data stg_pinterest_ad_group_report_data->stg_pinterest_campaign_history_data stg_pinterest_pin_promotion_history_data stg_pinterest_pin_promotion_history_data stg_pinterest_pin_promotion_history_data->snapshot_pinterest_ad_group_history_data stg_pinterest_campaign_history_data->snapshot_pinterest_advertiser_history_data stg_pinterest_pin_promotion_report_data stg_pinterest_pin_promotion_report_data stg_pinterest_pin_promotion_report_data->snapshot_pinterest_advertiser_history_data stg_pinterest_pin_promotion_report_data->snapshot_pinterest_ad_group_history_data stg_pinterest_pin_promotion_report_data->stg_pinterest_pin_promotion_history_data stg_pinterest_pin_promotion_report_data->stg_pinterest_campaign_history_data stg_pinterest_keyword_history_data stg_pinterest_keyword_history_data stg_pinterest_keyword_history_data->snapshot_pinterest_ad_group_history_data stg_pinterest_keyword_report_data stg_pinterest_keyword_report_data stg_pinterest_keyword_report_data->snapshot_pinterest_advertiser_history_data stg_pinterest_keyword_report_data->snapshot_pinterest_ad_group_history_data stg_pinterest_keyword_report_data->stg_pinterest_pin_promotion_history_data stg_pinterest_keyword_report_data->stg_pinterest_campaign_history_data stg_pinterest_keyword_report_data->stg_pinterest_keyword_history_data stg_pinterest_advertiser_report_data stg_pinterest_advertiser_report_data stg_pinterest_advertiser_report_data->snapshot_pinterest_advertiser_history_data

cocoon_join.yml (Document the joins)

join_graph:
- table_name: stg_pinterest_campaign_history_data
  primary_key: campaign_id
  foreign_keys:
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_id
- table_name: stg_pinterest_ad_group_report_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: stg_pinterest_campaign_history_data
      column: campaign_id
  - column: ad_group_id
    reference:
      table_name: snapshot_pinterest_ad_group_history_data
      column: ad_group_id
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_id
- table_name: stg_pinterest_campaign_report_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: stg_pinterest_campaign_history_data
      column: campaign_id
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_id
- table_name: stg_pinterest_keyword_report_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: stg_pinterest_campaign_history_data
      column: campaign_id
  - column: keyword_id
    reference:
      table_name: stg_pinterest_keyword_history_data
      column: keyword_id
  - column: pin_promotion_id
    reference:
      table_name: stg_pinterest_pin_promotion_history_data
      column: promoted_pin_id
  - column: ad_group_id
    reference:
      table_name: snapshot_pinterest_ad_group_history_data
      column: ad_group_id
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_id
- table_name: stg_pinterest_pin_promotion_report_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: stg_pinterest_campaign_history_data
      column: campaign_id
  - column: pin_promotion_id
    reference:
      table_name: stg_pinterest_pin_promotion_history_data
      column: promoted_pin_id
  - column: ad_group_id
    reference:
      table_name: snapshot_pinterest_ad_group_history_data
      column: ad_group_id
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_id
- table_name: snapshot_pinterest_ad_group_history_data
  foreign_keys:
  - column: campaign_id
    reference:
      table_name: stg_pinterest_campaign_history_data
      column: campaign_id
  primary_key: ad_group_id
- table_name: stg_pinterest_keyword_history_data
  primary_key: keyword_id
  foreign_keys:
  - column: ad_group_id
    reference:
      table_name: snapshot_pinterest_ad_group_history_data
      column: ad_group_id
- table_name: stg_pinterest_pin_promotion_history_data
  primary_key: promoted_pin_id
  foreign_keys:
  - column: ad_group_id
    reference:
      table_name: snapshot_pinterest_ad_group_history_data
      column: ad_group_id
- table_name: snapshot_pinterest_advertiser_history_data
  primary_key: advertiser_id
  foreign_keys: []
- table_name: stg_pinterest_advertiser_report_data
  foreign_keys:
  - column: advertiser_id
    reference:
      table_name: snapshot_pinterest_advertiser_history_data
      column: advertiser_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: Campaigns
  entity_description: Represents individual advertising campaigns on Pinterest, including
    their settings, budgets, and status.
  table_name: stg_pinterest_campaign_history_data
  primary_key: campaign_id
- entity_name: Keywords
  entity_description: Represents keywords used in Pinterest ad campaigns, including
    their association with ad groups and campaigns.
  table_name: stg_pinterest_keyword_history_data
  primary_key: keyword_id
- entity_name: Promoted Pins
  entity_description: Represents individual promoted pins on Pinterest, including
    their metadata, associated ad groups, and promotional details.
  table_name: stg_pinterest_pin_promotion_history_data
  primary_key: promoted_pin_id
- entity_name: Ad Groups
  entity_description: Represents current ad groups on Pinterest, including their settings,
    status, and associated campaign information.
  table_name: snapshot_pinterest_ad_group_history_data
  primary_key: ad_group_id
- entity_name: Advertisers
  entity_description: Represents current advertiser accounts on Pinterest, including
    their account details, billing information, and status.
  table_name: snapshot_pinterest_advertiser_history_data
  primary_key: advertiser_id
relations:
- relation_name: AdvertiserPinterestCampaigns
  relation_description: This tracks Campaigns created and managed by Advertisers on
    Pinterest's advertising platform.
  table_name: stg_pinterest_campaign_history_data
  entities:
  - Campaigns
  - Advertisers
- relation_name: AdGroupKeywords
  relation_description: Keywords are associated with Ad Groups in Pinterest advertising
    campaigns, allowing targeted keyword-based ad placement.
  table_name: stg_pinterest_keyword_history_data
  entities:
  - Keywords
  - Ad Groups
- relation_name: PromotedPinAdGroupAssociation
  relation_description: Promoted Pins are associated with Ad Groups, which group together
    multiple promoted pins for a specific advertising campaign on Pinterest.
  table_name: stg_pinterest_pin_promotion_history_data
  entities:
  - Promoted Pins
  - Ad Groups
- relation_name: CampaignAdGroups
  relation_description: Ad Groups are subdivisions within Campaigns, allowing for
    more targeted advertising strategies and budget allocation.
  table_name: snapshot_pinterest_ad_group_history_data
  entities:
  - Ad Groups
  - Campaigns
- relation_description: Advertisers create Campaigns, which contain Ad Groups, forming
    a hierarchical structure for organizing Pinterest advertising efforts.
  table_name: stg_pinterest_ad_group_report_data
  entities:
  - Campaigns
  - Ad Groups
  - Advertisers
- relation_description: This tracks the daily performance metrics of advertising Campaigns
    run by Advertisers on Pinterest.
  table_name: stg_pinterest_campaign_report_data
  entities:
  - Campaigns
  - Advertisers
- relation_description: Advertisers create Campaigns containing Ad Groups, which target
    specific Keywords and promote Promoted Pins on Pinterest.
  table_name: stg_pinterest_keyword_report_data
  entities:
  - Campaigns
  - Keywords
  - Promoted Pins
  - Ad Groups
  - Advertisers
- relation_description: Advertisers create Campaigns containing Ad Groups, which include
    Promoted Pins for targeted advertising on Pinterest.
  table_name: stg_pinterest_pin_promotion_report_data
  entities:
  - Campaigns
  - Promoted Pins
  - Ad Groups
  - Advertisers
- relation_description: This table contains daily performance metrics for a single
    Advertiser's campaigns on Pinterest.
  table_name: stg_pinterest_advertiser_report_data
  entities:
  - Advertisers
story:
- relation_name: AdvertiserPinterestCampaigns
  story_line: Advertisers create and manage campaigns on Pinterest's advertising platform.
- relation_name: CampaignAdGroups
  story_line: Advertisers divide campaigns into targeted ad groups.
- relation_name: AdGroupKeywords
  story_line: Advertisers assign keywords to ad groups for targeted placement.
- relation_name: PromotedPinAdGroupAssociation
  story_line: Advertisers link promoted pins to specific ad groups.