diff --git a/dbt_project.yml b/dbt_project.yml index 29879db..87ef022 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -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 \ No newline at end of file diff --git a/macros/timestamp_add.sql b/macros/timestamp_add.sql deleted file mode 100644 index 379cf31..0000000 --- a/macros/timestamp_add.sql +++ /dev/null @@ -1,33 +0,0 @@ -{% macro timestamp_add(datepart, interval, from_timestamp) -%} - -{{ adapter_macro('linkedin.timestamp_add', datepart, interval, from_timestamp) }} - -{%- endmacro %} - - -{% macro default__timestamp_add(datepart, interval, from_timestamp) %} - - timestampadd( - {{ datepart }}, - {{ interval }}, - {{ from_timestamp }} - ) - -{% endmacro %} - - -{% macro bigquery__timestamp_add(datepart, interval, from_timestamp) %} - - timestamp_add({{ from_timestamp }}, interval {{ interval }} {{ datepart }}) - -{% endmacro %} - -{% macro redshift__timestamp_add(datepart, interval, from_timestamp) %} - - dateadd( - {{ datepart }}, - {{ interval }}, - {{ from_timestamp }} - ) - -{% endmacro %} \ No newline at end of file diff --git a/models/linkedin__ad_adapter.sql b/models/linkedin__ad_adapter.sql index d8deeaf..eb85570 100644 --- a/models/linkedin__ad_adapter.sql +++ b/models/linkedin__ad_adapter.sql @@ -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 ( @@ -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()) }}) ) diff --git a/packages.yml b/packages.yml index 0132db9..d4d7cdc 100644 --- a/packages.yml +++ b/packages.yml @@ -1,6 +1,6 @@ -packages: - - package: fishtown-analytics/dbt_utils - version: 0.5.0 - +packages: - package: fivetran/linkedin_source - version: 0.1.0 \ No newline at end of file + version: [">=0.2.0", "<0.3.0"] + + - git: "https://github.com/fivetran/dbt_fivetran_utils.git" + warn-unpinned: false \ No newline at end of file