Skip to content

Commit

Permalink
Merge pull request #6 from fivetran/updates
Browse files Browse the repository at this point in the history
Updates
  • Loading branch information
fivetran-jamie authored Nov 2, 2020
2 parents ccde05e + af31886 commit 2fee9a2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 59 deletions.
18 changes: 10 additions & 8 deletions dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@

name: 'linkedin'
version: '1.0.0'
version: '0.2.0'
config-version: 2
require-dbt-version: [">=0.18.0", "<0.19.0"]

source-paths: ["models"]
analysis-paths: ["analysis"]
test-paths: ["tests"]
data-paths: ["data"]
macro-paths: ["macros"]
snapshot-paths: ["snapshots"]
vars:
linkedin:
ad_analytics_by_creative: "{{ ref('stg_linkedin__ad_analytics_by_creative') }}"
creative_history: "{{ ref('stg_linkedin__creative_history') }}"
campaign_history: "{{ ref('stg_linkedin__campaign_history') }}"
campaign_group_history: "{{ ref('stg_linkedin__campaign_group_history') }}"
account_history: "{{ ref('stg_linkedin__account_history') }}"

models:
linkedin:
materialized: table
materialized: table
33 changes: 0 additions & 33 deletions macros/timestamp_add.sql

This file was deleted.

26 changes: 13 additions & 13 deletions models/linkedin__ad_adapter.sql
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
with metrics as (

select *
from {{ ref('stg_linkedin__ad_analytics_by_creative') }}
from {{ var('ad_analytics_by_creative') }}

), creatives as (

select *
from {{ ref('stg_linkedin__creative_history') }}
from {{ var('creative_history') }}

), campaigns as (

select *
from {{ ref('stg_linkedin__campaign_history') }}
from {{ var('campaign_history') }}

), campaign_groups as (

select *
from {{ ref('stg_linkedin__campaign_group_history') }}
from {{ var('campaign_group_history') }}

), accounts as (

select *
from {{ ref('stg_linkedin__account_history') }}
from {{ var('account_history') }}

), joined as (

Expand Down Expand Up @@ -49,20 +49,20 @@ with metrics as (
from metrics
left join creatives
on metrics.creative_id = creatives.creative_id
and {{ timestamp_add('day', 1, 'metrics.date_day') }} >= creatives.valid_from
and {{ timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(creatives.valid_to, {{ timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} >= creatives.valid_from
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(creatives.valid_to, {{ fivetran_utils.timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
left join campaigns
on creatives.campaign_id = campaigns.campaign_id
and {{ timestamp_add('day', 1, 'metrics.date_day') }} >= campaigns.valid_from
and {{ timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(campaigns.valid_to, {{ timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} >= campaigns.valid_from
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(campaigns.valid_to, {{ fivetran_utils.timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
left join campaign_groups
on campaigns.campaign_group_id = campaign_groups.campaign_group_id
and {{ timestamp_add('day', 1, 'metrics.date_day') }} >= campaign_groups.valid_from
and {{ timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(campaign_groups.valid_to, {{ timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} >= campaign_groups.valid_from
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(campaign_groups.valid_to, {{ fivetran_utils.timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
left join accounts
on campaign_groups.account_id = accounts.account_id
and {{ timestamp_add('day', 1, 'metrics.date_day') }} >= accounts.valid_from
and {{ timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(accounts.valid_to, {{ timestamp_add('day', 1, dbt_utils.current_timestamp()) }})
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} >= accounts.valid_from
and {{ fivetran_utils.timestamp_add('day', 1, 'metrics.date_day') }} <= coalesce(accounts.valid_to, {{ fivetran_utils.timestamp_add('day', 1, dbt_utils.current_timestamp()) }})

)

Expand Down
10 changes: 5 additions & 5 deletions packages.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
packages:
- package: fishtown-analytics/dbt_utils
version: 0.5.0

packages:
- package: fivetran/linkedin_source
version: 0.1.0
version: [">=0.2.0", "<0.3.0"]

- git: "https://github.com/fivetran/dbt_fivetran_utils.git"
warn-unpinned: false

0 comments on commit 2fee9a2

Please sign in to comment.