Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature that added ad squad & campaign in the ad report #33

Merged
merged 11 commits into from
Feb 19, 2025
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,25 @@
# dbt_snapchat_ads version.version
# dbt_snapchat_ads v0.8.0
This release introduces the following updates:

## Breaking Changes
- Adds ad squad and campaign details to the `snapchat_ads__ad_report` model, so that they can eventually be incorporated in the `dbt_ad_reporting` package for the `ad_reporting__ad_report` model. ([#33](https://github.com/fivetran/dbt_snapchat_ads/pull/33))
- Fields added include:
- `ad_squad_id`
- `ad_squad_name`
- `campaign_id`
- `campaign_name`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you consolidate this into the one bullet above. "Fields added include:" doesn't need to be a separate bullet. But I would like the separate fields to be their own sub bullets still.


## Under The Hood
- Updated the tests to include `ad_squad_id` and `campaign_id` in `snapchat.yml` for `snapchat_ads__ad_report` and `snapchat_ads__url_report` to more closely align with other ad reporting packages. ([#33](https://github.com/fivetran/dbt_snapchat_ads/pull/33))
- Added integrity test to ensure the `snapchat_ads__ad_report` maintains the same row grain count for `ad_id` and `date_day` betweens the source and end models. ([#33](https://github.com/fivetran/dbt_snapchat_ads/pull/33))

## Documentation
- Added Quickstart model counts to README. ([#30](https://github.com/fivetran/dbt_snapchat_ads/pull/30))
- Corrected references to connectors and connections in the README. ([#30](https://github.com/fivetran/dbt_snapchat_ads/pull/30))
- Updated `snapchat.yml` with new above field additions. ([#33](https://github.com/fivetran/dbt_snapchat_ads/pull/33))

## Contributors
- [@JeremyDOwens](https://github.com/JeremyDOwens) ([#32](https://github.com/fivetran/dbt_snapchat_ads/pull/32))

# dbt_snapchat_ads v0.7.0
[PR #28](https://github.com/fivetran/dbt_snapchat_ads/pull/28) includes the following **BREAKING CHANGE** updates:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ If you are not using the [Ad Reporting](https://github.com/fivetran/dbt_ad_repor
```yml
packages:
- package: fivetran/snapchat_ads
version: [">=0.7.0", "<0.8.0"] # we recommend using ranges to capture non-breaking changes automatically
version: [">=0.8.0", "<0.9.0"] # we recommend using ranges to capture non-breaking changes automatically
```

Do NOT include the `snapchat_ads_source` package in this file. The transformation package itself has a dependency on it and will install the source package as well.
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'snapchat_ads'
version: '0.6.2'
version: '0.8.0'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yikes, looks like we missed updating this in the last release.

config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
vars:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

253 changes: 214 additions & 39 deletions docs/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/manifest.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: 'snapchat_ads_integration_tests'
version: '0.7.0'
version: '0.8.0'
profile: 'integration_tests'
config-version: 2

vars:
vars:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace removal

Suggested change
vars:
vars:

snapchat_ads_source:
snapchat_ads_schema: snapchat_ads_integration_tests_6
snapchat_ads_ad_account_history_identifier: "snapchat_ad_account_history_data"
Expand Down
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you're making a new test, can you also update the consistency tests to ensure the conversions is included moving forward.

Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{ config(
tags="fivetran_validations",
enabled=var('fivetran_validation_tests_enabled', false)
) }}

with ad_day_source as (

select
ad_id,
cast(date_hour as date) as date_day_source
from {{ ref('stg_snapchat_ads__ad_hourly_report') }}
{{ dbt_utils.group_by(2) }}
),

ad_day_end as (

select
ad_id,
date_day as date_day_end
from {{ ref('snapchat_ads__ad_report') }}

{{ dbt_utils.group_by(2) }}
),

final as (
-- test will fail if any rows from source not found in end
(select * from ad_day_source
except distinct
select * from ad_day_end)

union all -- union since we only care if rows are produced

-- test will fail if any rows from end are not found in source
(select * from ad_day_end
except distinct
select * from ad_day_source)
)

select *
from final
12 changes: 12 additions & 0 deletions models/snapchat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ models:
combination_of_columns:
- source_relation
- ad_id
- ad_squad_id
- campaign_id
- date_day
columns:
- name: source_relation
Expand All @@ -64,6 +66,14 @@ models:
description: The name of the account in Snapchat.
- name: ad_name
description: The name of the ad in Snapchat.
- name: ad_squad_id
description: The ID of the ad squad in Snapchat.
- name: ad_squad_name
description: The name of the ad squad in Snapchat.
- name: campaign_id
description: The ID of the campaign in Snapchat.
- name: campaign_name
description: The name of the campaign in Snapchat.
- name: currency
description: The current used by the account in Snapchat.
- name: spend
Expand Down Expand Up @@ -171,6 +181,8 @@ models:
combination_of_columns:
- source_relation
- ad_id
- ad_squad_id
- campaign_id
- date_day
config:
# Below is so we don't run this test if the user has allowed urls to have null entries
Expand Down
25 changes: 24 additions & 1 deletion models/snapchat_ads__ad_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@ with ad_hourly as (
from {{ var('ad_history') }}
where is_most_recent_record = true

), ad_squads as (

select *
from {{ var('ad_squad_history') }}
where is_most_recent_record = true

), campaigns as (

select *
from {{ var('campaign_history') }}
where is_most_recent_record = true


), aggregated as (

select
Expand All @@ -36,6 +49,10 @@ with ad_hourly as (
account.ad_account_name,
ad_hourly.ad_id,
ads.ad_name,
ad_squads.ad_squad_id,
ad_squads.ad_squad_name,
campaigns.campaign_id,
campaigns.campaign_name,
account.currency,
sum(ad_hourly.swipes) as swipes,
sum(ad_hourly.impressions) as impressions,
Expand All @@ -57,8 +74,14 @@ with ad_hourly as (
left join account
on creatives.ad_account_id = account.ad_account_id
and creatives.source_relation = account.source_relation
left join ad_squads
on ads.ad_squad_id = ad_squads.ad_squad_id
and ads.source_relation = ad_squads.source_relation
left join campaigns
on ad_squads.campaign_id = campaigns.campaign_id
and ad_squads.source_relation = campaigns.source_relation

{{ dbt_utils.group_by(7) }}
{{ dbt_utils.group_by(11) }}

)

Expand Down