Skip to content

Commit

Permalink
Merge pull request #30 from fivetran/MagicBot/package-extract-url-par…
Browse files Browse the repository at this point in the history
…ameters

Extract URL Parameter Macro Update
  • Loading branch information
fivetran-joemarkiewicz authored Dec 14, 2023
2 parents 4a87f2c + 7efd943 commit 8930ed6
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 32 deletions.
13 changes: 13 additions & 0 deletions .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
@@ -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
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

env/
target/
dbt_modules/
logs/

package-lock.yml
dbt_packages/
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# dbt_microsoft_ads v0.7.1

[PR #30](https://github.com/fivetran/dbt_microsoft_ads/pull/30) includes the following updates:
## Bug Fixes
- This package now leverages the new `microsoft_ads_extract_url_parameter()` macro 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()` macro in the next breaking change of this package.
## Under the Hood
- Included auto-releaser GitHub Actions workflow to automate future releases.

# dbt_microsoft_ads v0.7.0
[PR #28](https://github.com/fivetran/dbt_microsoft_ads/pull/28) includes the following updates:

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: 'microsoft_ads'
version: '0.7.0'
version: '0.7.1'
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.

24 changes: 12 additions & 12 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.

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

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'microsoft_ads_integration_tests'
version: '0.7.0'
version: '0.7.1'
profile: 'integration_tests'
config-version: 2

Expand Down
6 changes: 2 additions & 4 deletions integration_tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
dbt-snowflake>=1.3.0,<2.0.0
dbt-bigquery>=1.3.0,<2.0.0
dbt-redshift>=1.3.0,<1.5.0
dbt-redshift>=1.3.0,<2.0.0
dbt-postgres>=1.3.0,<2.0.0
dbt-spark>=1.3.0,<2.0.0
dbt-spark[PyHive]>=1.3.0,<2.0.0
dbt-databricks>=1.3.0,<2.0.0

oscrypto @ git+https://github.com/wbond/oscrypto.git@d5f3437
dbt-databricks>=1.6.0,<2.0.0
20 changes: 20 additions & 0 deletions macros/microsoft_ads_extract_url_parameters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% macro microsoft_ads_extract_url_parameter(field, url_parameter) -%}

{{ return(adapter.dispatch('microsoft_ads_extract_url_parameter', 'microsoft_ads') (field, url_parameter)) }}

{% endmacro %}


{% macro default__microsoft_ads_extract_url_parameter(field, url_parameter) -%}

{{ dbt_utils.get_url_parameter(field, url_parameter) }}

{%- endmacro %}


{% macro spark__microsoft_ads_extract_url_parameter(field, url_parameter) -%}

{%- set formatted_url_parameter = "'" + url_parameter + "=([^&]+)'" -%}
nullif(regexp_extract({{ field }}, {{ formatted_url_parameter }}, 1), '')

{%- endmacro %}
18 changes: 9 additions & 9 deletions models/microsoft_ads__url_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,19 @@ joined as (

{% if var('microsoft_ads_auto_tagging_enabled', false) %}

coalesce( {{ dbt_utils.get_url_parameter('ads.final_url', 'utm_source') }} , 'Bing') as utm_source,
coalesce( {{ dbt_utils.get_url_parameter('ads.final_url', 'utm_medium') }}, 'cpc') as utm_medium,
coalesce( {{ dbt_utils.get_url_parameter('ads.final_url', 'utm_campaign') }}, campaigns.campaign_name) as utm_campaign,
coalesce( {{ dbt_utils.get_url_parameter('ads.final_url', 'utm_content') }}, ad_groups.ad_group_name) as utm_content,
coalesce( {{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_source') }} , 'Bing') as utm_source,
coalesce( {{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_medium') }}, 'cpc') as utm_medium,
coalesce( {{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_campaign') }}, campaigns.campaign_name) as utm_campaign,
coalesce( {{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_content') }}, ad_groups.ad_group_name) as utm_content,
{% else %}

{{ dbt_utils.get_url_parameter('ads.final_url', 'utm_source') }} as utm_source,
{{ dbt_utils.get_url_parameter('ads.final_url', 'utm_medium') }} as utm_medium,
{{ dbt_utils.get_url_parameter('ads.final_url', 'utm_campaign') }} as utm_campaign,
{{ dbt_utils.get_url_parameter('ads.final_url', 'utm_content') }} as utm_content,
{{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_source') }} as utm_source,
{{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_medium') }} as utm_medium,
{{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_campaign') }} as utm_campaign,
{{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_content') }} as utm_content,
{% endif %}

{{ dbt_utils.get_url_parameter('ads.final_url', 'utm_term') }} as utm_term,
{{ microsoft_ads.microsoft_ads_extract_url_parameter('ads.final_url', 'utm_term') }} as utm_term,
sum(report.clicks) as clicks,
sum(report.impressions) as impressions,
sum(report.spend) as spend
Expand Down

0 comments on commit 8930ed6

Please sign in to comment.