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

reach + frequency metrics #35

Merged
merged 9 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 10 additions & 36 deletions .github/PULL_REQUEST_TEMPLATE/maintainer_pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,22 @@
**This PR will result in the following new package version:**
<!--- Please add details around your decision for breaking vs non-breaking version upgrade. If this is a breaking change, were backwards-compatible options explored? -->

**Please detail what change(s) this PR introduces and any additional information that should be known during the review of this PR:**
**Please provide the finalized CHANGELOG entry which details the relevant changes included in this PR:**
<!--- Copy/paste the CHANGELOG for this version below. -->

## PR Checklist
### Basic Validation
Please acknowledge that you have successfully performed the following commands locally:
- [ ] dbt compile
- [ ] dbt run –full-refresh
- [ ] dbt run
- [ ] dbt test
- [ ] dbt run –vars (if applicable)
- [ ] dbt run –full-refresh && dbt test
- [ ] dbt run (if incremental models are present)

Before marking this PR as "ready for review" the following have been applied:
- [ ] The appropriate issue has been linked and tagged
- [ ] You are assigned to the corresponding issue and this PR
- [ ] The appropriate issue has been linked, tagged, and properly assigned
- [ ] All necessary documentation and version upgrades have been applied
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)
- [ ] BuildKite integration tests are passing
- [ ] Detailed validation steps have been provided below

### Detailed Validation
Please acknowledge that the following validation checks have been performed prior to marking this PR as "ready for review":
- [ ] You have validated these changes and assure this PR will address the respective Issue/Feature.
- [ ] You are reasonably confident these changes will not impact any other components of this package or any dependent packages.
- [ ] You have provided details below around the validation steps performed to gain confidence in these changes.
<!--- Provide the steps you took to validate your changes below. -->

### Standard Updates
Please acknowledge that your PR contains the following standard updates:
- Package versioning has been appropriately indexed in the following locations:
- [ ] indexed within dbt_project.yml
- [ ] indexed within integration_tests/dbt_project.yml
- [ ] CHANGELOG has individual entries for each respective change in this PR
<!--- If there is a parallel upstream change, remember to reference the corresponding CHANGELOG as an individual entry. -->
- [ ] README updates have been applied (if applicable)
<!--- Remember to check the following README locations for common updates. →
<!--- Suggested install range (needed for breaking changes) →
<!--- Dependency matrix is appropriately updated (if applicable) →
<!--- New variable documentation (if applicable) -->
- [ ] DECISIONLOG updates have been updated (if applicable)
- [ ] Appropriate yml documentation has been added (if applicable)

### dbt Docs
Please acknowledge that after the above were all completed the below were applied to your branch:
- [ ] docs were regenerated (unless this PR does not include any code or yml updates)

### If you had to summarize this PR in an emoji, which would it be?
<!--- For a complete list of markdown compatible emojis check our this git repo (https://gist.github.com/rxaviers/7360908) -->
:dancer:
Please share any and all of your validation steps:
<!--- Provide the steps you took to validate your changes below. -->
13 changes: 11 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# dbt_facebook_ads_source v0.7.3
[PR #35](https://github.com/fivetran/dbt_facebook_ads_source/pull/35) includes the following updates:

## Bug Fixes
- Resolved the "duplicate column" error that would arise when the `facebook_ads__basic_ad_passthrough_metrics` variable included `reach` or `frequency`. `Reach` and `frequency` are included by default in the `stg_facebook_ads__basic_ad` model but will only persist to downstream transform models if specified in the `facebook_ads__basic_ad_passthrough_metrics` variable.
fivetran-jamie marked this conversation as resolved.
Show resolved Hide resolved
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we call out how we resolved it in a sub-bullet using a for loop in the specific models/macros? Doesn't have to be too involved, just always nice to explain how to the customer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

added!


## Under the Hood
- Updated the maintainer PR template to our most up-to-date standards.

# dbt_facebook_ads_source v0.7.2
[PR #33](https://github.com/fivetran/dbt_facebook_ads_source/pull/33) includes the following updates:

Expand All @@ -23,10 +32,10 @@

# dbt_facebook_ads_source v0.UPDATE.UPDATE
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this Under the Hood section be incorporated into a release (and this v.0.UPDATE.UPDATE line be removed)?


## Under the Hood:

## Under the Hood:
- Incorporated the new `fivetran_utils.drop_schemas_automation` macro into the end of each Buildkite integration test job.
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know which release these changes came from? We should probably move these bullets to that release section.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated!

- Updated the pull request [templates](/.github).

# dbt_facebook_ads_source v0.6.0

## 🚨 Breaking Changes 🚨:
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: 'facebook_ads_source'
version: '0.7.2'
version: '0.7.3'
config-version: 2
require-dbt-version: [">=1.3.0", "<2.0.0"]
models:
Expand Down
2 changes: 1 addition & 1 deletion docs/catalog.json

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: 'facebook_ads_source_integration_tests_2'
version: '0.7.2'
version: '0.7.3'
profile: 'integration_tests'
config-version: 2

vars:
facebook_ads__basic_ad_passthrough_metrics:
- name: "reach"
- name: "frequency"
alias: "fake_freq_name"
fivetran-joemarkiewicz marked this conversation as resolved.
Show resolved Hide resolved

facebook_ads_schema: facebook_ads_source_integration_tests_2
facebook_ads_source:
facebook_ads_account_history_identifier: "facebook_ads_account_history_data"
Expand Down
14 changes: 13 additions & 1 deletion macros/get_basic_ad_columns.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,19 @@
{"name": "frequency", "datatype": dbt.type_float()}
] %}

{{ fivetran_utils.add_pass_through_columns(columns, var('facebook_ads__basic_ad_passthrough_metrics')) }}
{#
Reach and Frequency are not included in downstream models by default, though they are included in the staging model.
The below ensures that users can add Reach and Frequency to downstream models with the `facebook_ads__basic_ad_passthrough_metrics` variable
while avoiding duplicate column errors.
#}
{% set unique_passthrough = [] %}
{% for field in var('facebook_ads__basic_ad_passthrough_metrics') %}
{% if (field.alias if field.alias else field.name)|lower not in ('reach', 'frequency') %}
{% do unique_passthrough.append({"name": field.name, "alias": field.alias}) %}
{% endif %}
{% endfor %}

{{ fivetran_utils.add_pass_through_columns(columns, unique_passthrough) }}

{{ return(columns) }}

Expand Down
23 changes: 20 additions & 3 deletions models/stg_facebook_ads__basic_ad.sql
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,26 @@ final as (
cast(account_id as {{ dbt.type_bigint() }}) as account_id,
impressions,
coalesce(inline_link_clicks,0) as clicks,
spend,
reach,
frequency
spend

{#
Reach and Frequency are not included in downstream models by default, though they are included in the staging model.
The below ensures that users can add Reach and Frequency to downstream models with the `facebook_ads__basic_ad_passthrough_metrics` variable
while avoiding duplicate column errors.
#}
{%- set check = [] %}
{%- for field in var('facebook_ads__basic_ad_passthrough_metrics') -%}
{%- set field_name = field.alias|default(field.name)|lower %}
{% if field_name in ['reach', 'frequency'] %}
{% do check.append(field_name) %}
{% endif %}
{%- endfor %}

{%- for metric in ['reach', 'frequency'] -%}
{% if metric not in check %}
, {{ metric }}
{% endif %}
{%- endfor %}

{{ fivetran_utils.fill_pass_through_columns('facebook_ads__basic_ad_passthrough_metrics') }}
from fields
Expand Down