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

Extract URL Parameter Macro Update #8

Merged
merged 4 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
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
5 changes: 3 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
target/
dbt_modules/
logs/

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

[PR #8](https://github.com/fivetran/dbt_reddit_ads/pull/8) includes the following updates:
## Bug Fixes
- This package now leverages the new `reddit_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_reddit_ads v0.2.0
[PR #5](https://github.com/fivetran/dbt_reddit_ads/pull/5) includes the following updates:
## Feature update 🎉
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: 'reddit_ads'
version: '0.2.0'
version: '0.2.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.

10 changes: 5 additions & 5 deletions integration_tests/ci/sample.profiles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ integration_tests:
pass: "{{ env_var('CI_REDSHIFT_DBT_PASS') }}"
dbname: "{{ env_var('CI_REDSHIFT_DBT_DBNAME') }}"
port: 5439
schema: reddit_ads_integration_tests_1
schema: reddit_ads_integration_tests_3
threads: 8
bigquery:
type: bigquery
method: service-account-json
project: 'dbt-package-testing'
schema: reddit_ads_integration_tests_1
schema: reddit_ads_integration_tests_3
threads: 8
keyfile_json: "{{ env_var('GCLOUD_SERVICE_KEY') | as_native }}"
snowflake:
Expand All @@ -33,7 +33,7 @@ integration_tests:
role: "{{ env_var('CI_SNOWFLAKE_DBT_ROLE') }}"
database: "{{ env_var('CI_SNOWFLAKE_DBT_DATABASE') }}"
warehouse: "{{ env_var('CI_SNOWFLAKE_DBT_WAREHOUSE') }}"
schema: reddit_ads_integration_tests_1
schema: reddit_ads_integration_tests_3
threads: 8
postgres:
type: postgres
Expand All @@ -42,13 +42,13 @@ integration_tests:
pass: "{{ env_var('CI_POSTGRES_DBT_PASS') }}"
dbname: "{{ env_var('CI_POSTGRES_DBT_DBNAME') }}"
port: 5432
schema: reddit_ads_integration_tests_1
schema: reddit_ads_integration_tests_3
threads: 8
databricks:
catalog: "{{ env_var('CI_DATABRICKS_DBT_CATALOG') }}"
host: "{{ env_var('CI_DATABRICKS_DBT_HOST') }}"
http_path: "{{ env_var('CI_DATABRICKS_DBT_HTTP_PATH') }}"
schema: reddit_ads_integration_tests_1
schema: reddit_ads_integration_tests_3
threads: 8
token: "{{ env_var('CI_DATABRICKS_DBT_TOKEN') }}"
type: databricks
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'reddit_ads_integration_tests'
version: '0.2.0'
version: '0.2.1'
profile: 'integration_tests'
config-version: 2

vars:
reddit_ads_schema: reddit_ads_integration_tests_1
reddit_ads_schema: reddit_ads_integration_tests_3
reddit_ads_account_identifier: "reddit_ads_account_data"
reddit_ads_account_report_identifier: "reddit_ads_account_report_data"
reddit_ads_ad_identifier: "reddit_ads_ad_data"
Expand Down
20 changes: 20 additions & 0 deletions macros/reddit_ads_extract_url_parameters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% macro reddit_ads_extract_url_parameter(field, url_parameter) -%}

{{ return(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 %}
10 changes: 5 additions & 5 deletions models/reddit_ads__url_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
{{ reddit_ads.reddit_ads_extract_url_parameter('ads.click_url', 'utm_source') }} as utm_source,
{{ reddit_ads.reddit_ads_extract_url_parameter('ads.click_url', 'utm_medium') }} as utm_medium,
{{ reddit_ads.reddit_ads_extract_url_parameter('ads.click_url', 'utm_term') }} as utm_term,
{{ reddit_ads.reddit_ads_extract_url_parameter('ads.click_url', 'utm_content') }} as utm_content,
coalesce( {{ reddit_ads.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
Expand Down