Skip to content

Commit

Permalink
Merge pull request #19 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 f2d859e + 0be5267 commit 59c875e
Show file tree
Hide file tree
Showing 11 changed files with 53 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/auto-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ on:
jobs:
call-workflow-passing-data:
if: github.event.pull_request.merged
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@feature/auto-releaser
uses: fivetran/dbt_package_automations/.github/workflows/auto-release.yml@main
secrets: inherit
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ logs/
dbt_packages/
env/
.DS_Store
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_tiktok_ads_source v0.5.2

[PR #19](https://github.com/fivetran/dbt_tiktok_ads_source/pull/19) includes the following updates:
## Bug Fixes
- This package now leverages the new `tiktok_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_tiktok_ads_source v0.5.1
[PR #14](https://github.com/fivetran/dbt_tiktok_ads_source/pull/14) includes the following updates:
## Under the Hood:
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: 'tiktok_ads_source'
version: '0.5.1'
version: '0.5.2'
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.

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: 'tiktok_ads_source_integration_tests'
version: '0.5.1'
version: '0.5.2'
profile: 'integration_tests'
config-version: 2

Expand Down
20 changes: 20 additions & 0 deletions macros/tiktok_ads_extract_url_parameters.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{% macro tiktok_ads_extract_url_parameter(field, url_parameter) -%}

{{ return(adapter.dispatch('tiktok_ads_extract_url_parameter', 'tiktok_ads_source') (field, url_parameter)) }}

{% endmacro %}


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

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

{%- endmacro %}


{% macro spark__tiktok_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/stg_tiktok_ads__ad_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ final as (
{{ dbt.split_part('landing_page_url', "'?'", 1) }} as base_url,
{{ dbt_utils.get_url_host('landing_page_url') }} as url_host,
'/' || {{ dbt_utils.get_url_path('landing_page_url') }} as url_path,
{{ dbt_utils.get_url_parameter('landing_page_url', 'utm_source') }} as utm_source,
{{ dbt_utils.get_url_parameter('landing_page_url', 'utm_medium') }} as utm_medium,
{{ dbt_utils.get_url_parameter('landing_page_url', 'utm_campaign') }} as utm_campaign,
{{ dbt_utils.get_url_parameter('landing_page_url', 'utm_content') }} as utm_content,
{{ dbt_utils.get_url_parameter('landing_page_url', 'utm_term') }} as utm_term,
{{ tiktok_ads_source.tiktok_ads_extract_url_parameter('landing_page_url', 'utm_source') }} as utm_source,
{{ tiktok_ads_source.tiktok_ads_extract_url_parameter('landing_page_url', 'utm_medium') }} as utm_medium,
{{ tiktok_ads_source.tiktok_ads_extract_url_parameter('landing_page_url', 'utm_campaign') }} as utm_campaign,
{{ tiktok_ads_source.tiktok_ads_extract_url_parameter('landing_page_url', 'utm_content') }} as utm_content,
{{ tiktok_ads_source.tiktok_ads_extract_url_parameter('landing_page_url', 'utm_term') }} as utm_term,
landing_page_url,
row_number() over (partition by source_relation, ad_id order by updated_at desc) = 1 as is_most_recent_record
from fields
Expand Down

0 comments on commit 59c875e

Please sign in to comment.