diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml new file mode 100644 index 0000000..8ed5853 --- /dev/null +++ b/.github/workflows/auto-release.yml @@ -0,0 +1,13 @@ +name: 'auto release' +on: + pull_request: + types: + - closed + branches: + - main + +jobs: + call-workflow-passing-data: + if: github.event.pull_request.merged + uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@main + secrets: inherit \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index d44d4a8..fc46dc4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,12 @@ +# dbt_reddit_ads v0.2.1 + +[PR #]() includes the following updates: +## Bug Fixes +- This package now leverages the new `reddit_ads_extract_url_parameter()` for use in parsing out url parameters. This was added to create special logic for Databricks instances not supported by `dbt_utils.get_url_parameter()`. + - This macro will be replaced with the `fivetran_utils.extract_url_parameter()` in the next breaking change. +## Under the Hood +- Included auto-releaser GitHub Actions workflow to automate future releases. + # dbt_reddit_ads v0.2.0 [PR #5](https://github.com/fivetran/dbt_reddit_ads/pull/5) includes the following updates: ## Feature update 🎉 diff --git a/dbt_project.yml b/dbt_project.yml index a41e381..cf9147a 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -1,5 +1,5 @@ name: 'reddit_ads' -version: '0.2.0' +version: '0.2.1' config-version: 2 require-dbt-version: [">=1.3.0", "<2.0.0"] vars: diff --git a/integration_tests/dbt_project.yml b/integration_tests/dbt_project.yml index b44dca0..4d834c3 100644 --- a/integration_tests/dbt_project.yml +++ b/integration_tests/dbt_project.yml @@ -1,5 +1,5 @@ name: 'reddit_ads_integration_tests' -version: '0.2.0' +version: '0.2.1' profile: 'integration_tests' config-version: 2 diff --git a/macros/reddit_ads_extract_url_parameters.sql b/macros/reddit_ads_extract_url_parameters.sql new file mode 100644 index 0000000..b6a6343 --- /dev/null +++ b/macros/reddit_ads_extract_url_parameters.sql @@ -0,0 +1,20 @@ +{% macro reddit_ads_extract_url_parameter(field, url_parameter) -%} + +{{ adapter.dispatch('reddit_ads_extract_url_parameter', 'reddit_ads') (field, url_parameter) }} + +{% endmacro %} + + +{% macro default__reddit_ads_extract_url_parameter(field, url_parameter) -%} + +{{ dbt_utils.get_url_parameter(field, url_parameter) }} + +{%- endmacro %} + + +{% macro spark__reddit_ads_extract_url_parameter(field, url_parameter) -%} + +{%- set formatted_url_parameter = "'" + url_parameter + "=([^&]+)'" -%} +nullif(regexp_extract({{ field }}, {{ formatted_url_parameter }}, 1), '') + +{%- endmacro %} \ No newline at end of file diff --git a/models/reddit_ads__url_report.sql b/models/reddit_ads__url_report.sql index cbb10d1..29b76c8 100644 --- a/models/reddit_ads__url_report.sql +++ b/models/reddit_ads__url_report.sql @@ -49,11 +49,11 @@ joined as ( {{ dbt.split_part('ads.click_url', "'?'", 1) }} as base_url, {{ dbt_utils.get_url_host('ads.click_url') }} as url_host, '/' || {{ dbt_utils.get_url_path('ads.click_url') }} as url_path, - {{ dbt_utils.get_url_parameter('ads.click_url', 'utm_source') }} as utm_source, - {{ dbt_utils.get_url_parameter('ads.click_url', 'utm_medium') }} as utm_medium, - {{ dbt_utils.get_url_parameter('ads.click_url', 'utm_term') }} as utm_term, - {{ dbt_utils.get_url_parameter('ads.click_url', 'utm_content') }} as utm_content, - coalesce( {{ dbt_utils.get_url_parameter('ads.click_url', 'utm_campaign') }}, campaigns.campaign_name) as utm_campaign, + {{ pinterest_source.reddit_ads_extract_url_parameter('ads.click_url', 'utm_source') }} as utm_source, + {{ pinterest_source.reddit_ads_extract_url_parameter('ads.click_url', 'utm_medium') }} as utm_medium, + {{ pinterest_source.reddit_ads_extract_url_parameter('ads.click_url', 'utm_term') }} as utm_term, + {{ pinterest_source.reddit_ads_extract_url_parameter('ads.click_url', 'utm_content') }} as utm_content, + coalesce( {{ pinterest_source.reddit_ads_extract_url_parameter('ads.click_url', 'utm_campaign') }}, campaigns.campaign_name) as utm_campaign, sum(report.clicks) as clicks, sum(report.impressions) as impressions, sum(report.spend) as spend