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

release/v0.10.2 #36

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# dbt_pinterest_source v0.10.2

[PR #36](https://github.com/fivetran/dbt_pinterest_source/pull/36) includes the following updates:

## Bug Fixes
- Updated the `is_most_recent_record` window function in the following models to exclude the `source_relation` field from the partition statement when `pinterest_ads_union_schemas` or `pinterest_ads_union_databases` variables are empty. Also, modified it to skip the window function if the upstream table is empty, using the new `result_if_table_exists()` and `is_table_empty()` macros. This change addresses Redshift's issue with partitioning by constant expressions.
- `stg_pinterest_ads__ad_group_history`
- `stg_pinterest_ads__advertiser_history`
- `stg_pinterest_ads__campaign_history`
- `stg_pinterest_ads__keyword_history`
- `stg_pinterest_ads__pin_promotion_history`

## Contributors
- [@JessicaKMarkiewicz](https://github.com/JessicaKMarkiewicz) ([PR #35](https://github.com/fivetran/dbt_pinterest_source/pull/35))

# dbt_pinterest_source v0.10.1

[PR #31](https://github.com/fivetran/dbt_pinterest_source/pull/31) 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: 'pinterest_source'
version: '0.10.1'
version: '0.10.2'
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.

47 changes: 10 additions & 37 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.

1 change: 0 additions & 1 deletion docs/run_results.json

This file was deleted.

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: 'pinterest_source_integration_tests'
version: '0.10.1'
version: '0.10.2'
profile: 'integration_tests'
config-version: 2

Expand Down
17 changes: 17 additions & 0 deletions macros/is_table_empty.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{%- macro is_table_empty(table_name) -%}

{{ adapter.dispatch('is_table_empty', 'pinterest_source') (table_name) }}

{%- endmacro %}

{%- macro default__is_table_empty(table_name) -%}
{%- if execute and flags.WHICH in ('run', 'build') %}
{% set row_count_query %}
select 1 from {{ table_name }} limit 1
{% endset %}
{% set results = run_query(row_count_query) %}
{% if results.rows | length == 0 %}
{{ return("empty") }}
{% endif %}
{% endif -%}
{%- endmacro -%}
14 changes: 14 additions & 0 deletions macros/result_if_table_exists.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{%- macro result_if_table_exists(table_ref, result_statement, if_empty) -%}

{{ adapter.dispatch('result_if_table_exists', 'pinterest_source') (table_ref, result_statement, if_empty) }}

{%- endmacro -%}

{%- macro default__result_if_table_exists(table_ref, result_statement, if_empty) -%}
{%- set is_empty_result = pinterest_source.is_table_empty(table_ref) -%}
{%- if is_empty_result == "empty" %}
{{ if_empty }}
{%- else %}
{{ result_statement }}
{%- endif %}
{%- endmacro %}
8 changes: 7 additions & 1 deletion models/stg_pinterest_ads__ad_group_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fields as (
}}

from base
{{ pinterest_source.result_if_table_exists(
table_ref=ref('stg_pinterest_ads__ad_group_history_tmp'),
result_statement="",
if_empty="limit 0")
}}
),

final as (
Expand All @@ -40,7 +45,8 @@ final as (
placement_group,
start_time,
summary_status,
row_number() over (partition by source_relation, id order by _fivetran_synced desc) = 1 as is_most_recent_record
row_number() over (partition by id, source_relation order by _fivetran_synced desc) as is_most_recent_record

from fields
)

Expand Down
6 changes: 6 additions & 0 deletions models/stg_pinterest_ads__advertiser_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fields as (
}}

from base
{{ pinterest_source.result_if_table_exists(
table_ref=ref('stg_pinterest_ads__advertiser_history_tmp'),
result_statement="",
if_empty="limit 0")
}}
),

final as (
Expand All @@ -38,6 +43,7 @@ final as (
advertiser_permissions, -- permissions was renamed in macro
updated_time as updated_at,
row_number() over (partition by source_relation, id order by updated_time desc) = 1 as is_most_recent_record

from fields
)

Expand Down
6 changes: 6 additions & 0 deletions models/stg_pinterest_ads__campaign_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fields as (
}}

from base
{{ pinterest_source.result_if_table_exists(
table_ref=ref('stg_pinterest_ads__campaign_history_tmp'),
result_statement="",
if_empty="limit 0")
}}
),

final as (
Expand All @@ -39,6 +44,7 @@ final as (
_fivetran_synced,
created_time as created_at,
row_number() over (partition by source_relation, id order by _fivetran_synced desc) = 1 as is_most_recent_record

from fields
)

Expand Down
6 changes: 6 additions & 0 deletions models/stg_pinterest_ads__keyword_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ fields as (
}}

from base
{{ pinterest_source.result_if_table_exists(
table_ref=ref('stg_pinterest_ads__keyword_history_tmp'),
result_statement="",
if_empty="limit 0")
}}
),

final as (
Expand All @@ -40,6 +45,7 @@ final as (
match_type,
parent_type,
row_number() over (partition by source_relation, id order by _fivetran_synced desc) = 1 as is_most_recent_record

from fields
)

Expand Down
6 changes: 6 additions & 0 deletions models/stg_pinterest_ads__pin_promotion_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ fields as (
}}

from base
{{ pinterest_source.result_if_table_exists(
table_ref=ref('stg_pinterest_ads__pin_promotion_history_tmp'),
result_statement="",
if_empty="limit 0")
}}
),

final as (
Expand All @@ -48,6 +53,7 @@ final as (
creative_type,
_fivetran_synced,
row_number() over (partition by source_relation, id order by _fivetran_synced desc) = 1 as is_most_recent_record

from fields
)

Expand Down