Skip to content

Commit

Permalink
update casts
Browse files Browse the repository at this point in the history
  • Loading branch information
fivetran-catfritz committed Jul 20, 2023
1 parent 7e53ec0 commit 2724bc9
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 29 deletions.
4 changes: 2 additions & 2 deletions models/amazon_ads__account_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ fields as (
from report

left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(report.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = report.campaign_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id


{{ dbt_utils.group_by(5) }}
Expand Down
8 changes: 4 additions & 4 deletions models/amazon_ads__ad_group_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ fields as (
from report

left join ad_groups
on cast(ad_groups.ad_group_id as {{ dbt.type_string() }}) = cast(report.ad_group_id as {{ dbt.type_string() }})
on ad_groups.ad_group_id = report.ad_group_id
left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(ad_groups.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = ad_groups.campaign_id
left join portfolios
on cast(portfolios.portfolio_id as {{ dbt.type_string() }}) = cast(campaigns.portfolio_id as {{ dbt.type_string() }})
on portfolios.portfolio_id = campaigns.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id

{{ dbt_utils.group_by(15) }}
)
Expand Down
10 changes: 5 additions & 5 deletions models/amazon_ads__ad_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,15 @@ fields as (
from report

left join ads
on cast(ads.ad_id as {{ dbt.type_string() }}) = cast(report.ad_id as {{ dbt.type_string() }})
on ads.ad_id = report.ad_id
left join ad_groups
on cast(ad_groups.ad_group_id as {{ dbt.type_string() }}) = cast(report.ad_group_id as {{ dbt.type_string() }})
on ad_groups.ad_group_id = report.ad_group_id
left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(report.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = report.campaign_id
left join portfolios
on cast(portfolios.portfolio_id as {{ dbt.type_string() }}) = cast(campaigns.portfolio_id as {{ dbt.type_string() }})
on portfolios.portfolio_id = campaigns.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id

{{ dbt_utils.group_by(19) }}
)
Expand Down
6 changes: 3 additions & 3 deletions models/amazon_ads__campaign_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@ fields as (
from report

left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(report.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = report.campaign_id
left join portfolios
on cast(portfolios.portfolio_id as {{ dbt.type_string() }}) = cast(campaigns.portfolio_id as {{ dbt.type_string() }})
on portfolios.portfolio_id = campaigns.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id

{{ dbt_utils.group_by(13) }}
)
Expand Down
10 changes: 5 additions & 5 deletions models/amazon_ads__keyword_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ fields as (
from report

left join keywords
on cast(keywords.keyword_id as {{ dbt.type_string() }}) = cast(report.keyword_id as {{ dbt.type_string() }})
on keywords.keyword_id = report.keyword_id
left join ad_groups
on cast(ad_groups.ad_group_id as {{ dbt.type_string() }}) = cast(report.ad_group_id as {{ dbt.type_string() }})
on ad_groups.ad_group_id = report.ad_group_id
left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(report.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = report.campaign_id
left join portfolios
on cast(portfolios.portfolio_id as {{ dbt.type_string() }}) = cast(campaigns.portfolio_id as {{ dbt.type_string() }})
on portfolios.portfolio_id = campaigns.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id

{{ dbt_utils.group_by(18) }}
)
Expand Down
6 changes: 3 additions & 3 deletions models/amazon_ads__portfolio_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ fields as (
from portfolios

left join campaigns
on cast(campaigns.portfolio_id as {{ dbt.type_string() }}) = cast(portfolios.portfolio_id as {{ dbt.type_string() }})
on campaigns.portfolio_id = portfolios.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id
left join report
on cast(report.campaign_id as {{ dbt.type_string() }}) = cast(campaigns.campaign_id as {{ dbt.type_string() }})
on report.campaign_id = campaigns.campaign_id

{{ dbt_utils.group_by(15) }}
)
Expand Down
10 changes: 5 additions & 5 deletions models/amazon_ads__search_report.sql
Original file line number Diff line number Diff line change
Expand Up @@ -63,15 +63,15 @@ fields as (
from report

left join keywords
on cast(keywords.keyword_id as {{ dbt.type_string() }}) = cast(report.keyword_id as {{ dbt.type_string() }})
on keywords.keyword_id = report.keyword_id
left join ad_groups
on cast(ad_groups.ad_group_id as {{ dbt.type_string() }}) = cast(report.ad_group_id as {{ dbt.type_string() }})
on ad_groups.ad_group_id = report.ad_group_id
left join campaigns
on cast(campaigns.campaign_id as {{ dbt.type_string() }}) = cast(report.campaign_id as {{ dbt.type_string() }})
on campaigns.campaign_id = report.campaign_id
left join portfolios
on cast(portfolios.portfolio_id as {{ dbt.type_string() }}) = cast(campaigns.portfolio_id as {{ dbt.type_string() }})
on portfolios.portfolio_id = campaigns.portfolio_id
left join account_info
on cast(account_info.profile_id as {{ dbt.type_string() }}) = cast(campaigns.profile_id as {{ dbt.type_string() }})
on account_info.profile_id = campaigns.profile_id

{{ dbt_utils.group_by(18) }}
)
Expand Down
6 changes: 4 additions & 2 deletions models/intermediate/int_amazon_ads__portfolio_history.sql
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ with portfolios as (
{% for column in columns %}
{# set null for each column #}
{%- if column['name'] == 'id' -%}
cast(null as {{ dbt.type_bigint() }}) as portfolio_id
cast(null as {{ dbt.type_string() }}) as portfolio_id
{%- elif column['name'] == 'name' -%}
null as portfolio_name
cast(null as {{ dbt.type_string() }}) as portfolio_name
{%- elif column['name'] == 'profile_id' -%}
cast(null as {{ dbt.type_string() }}) as profile_id
{%- else -%}
null as {{column['name']}}
{%- endif -%}
Expand Down

0 comments on commit 2724bc9

Please sign in to comment.