Skip to content

Commit

Permalink
Fix for warning that tests are present on disabled models
Browse files Browse the repository at this point in the history
  • Loading branch information
bill-warner committed Dec 16, 2021
1 parent fadda79 commit 5c32d56
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 24 deletions.
9 changes: 6 additions & 3 deletions dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,12 @@ vars:
snowplow__heartbeat: 10
snowplow__backfill_limit_days: 30
snowplow__app_id: []
snowplow__enable_iab: false
snowplow__enable_ua: false
snowplow__enable_yauaa: false
# Setting default values for 3 enrichments below throughout package rather than here
# Workaround for a bug (https://github.com/dbt-labs/dbt-core/issues/3698).
# TODO: Return to having default values here once fixed.
# snowplow__enable_iab: false
# snowplow__enable_ua: false
# snowplow__enable_yauaa: false
snowplow__ua_bot_filter: true
snowplow__derived_tstamp_partitioned: true
snowplow__session_stitching: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,23 +87,23 @@ select

-- iab enrichment fields: set iab variable to true to enable
{{ snowplow_utils.get_optional_fields(
enabled=var('snowplow__enable_iab'),
enabled=var('snowplow__enable_iab', false),
fields=iab_fields(),
col_prefix='contexts_com_iab_snowplow_spiders_and_robots_1',
relation=ref('snowplow_web_base_events_this_run'),
relation_alias='ev') }},

-- ua parser enrichment fields: set ua_parser variable to true to enable
{{ snowplow_utils.get_optional_fields(
enabled=var('snowplow__enable_ua'),
enabled=var('snowplow__enable_ua', false),
fields=ua_fields(),
col_prefix='contexts_com_snowplowanalytics_snowplow_ua_parser_context_1',
relation=ref('snowplow_web_base_events_this_run'),
relation_alias='ev') }},

-- yauaa enrichment fields: set yauaa variable to true to enable
{{ snowplow_utils.get_optional_fields(
enabled=var('snowplow__enable_yauaa'),
enabled=var('snowplow__enable_yauaa', false),
fields=yauaa_fields(),
col_prefix='contexts_nl_basjes_yauaa_context_1',
relation=ref('snowplow_web_base_events_this_run'),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ select
-- optional fields, only populated if enabled.

-- iab enrichment fields: set iab variable to true to enable
{% if var('snowplow__enable_iab') %}
{% if var('snowplow__enable_iab', false) %}
iab.category,
iab.primary_impact,
iab.reason,
Expand All @@ -109,7 +109,7 @@ select
{% endif %}

-- ua parser enrichment fields: set ua_parser variable to true to enable
{% if var('snowplow__enable_ua') %}
{% if var('snowplow__enable_ua', false) %}
ua.useragent_family,
ua.useragent_major,
ua.useragent_minor,
Expand Down Expand Up @@ -138,7 +138,7 @@ select
{% endif %}

-- yauaa enrichment fields: set yauaa variable to true to enable
{% if var('snowplow__enable_yauaa') %}
{% if var('snowplow__enable_yauaa', false) %}
ya.device_class,
ya.agent_class,
ya.agent_name,
Expand Down Expand Up @@ -190,21 +190,21 @@ on ev.page_view_id = t.page_view_id
left join {{ ref('snowplow_web_pv_scroll_depth') }} sd
on ev.page_view_id = sd.page_view_id

{% if var('snowplow__enable_iab') -%}
{% if var('snowplow__enable_iab', false) -%}

left join {{ ref('snowplow_web_pv_iab') }} iab
on ev.page_view_id = iab.page_view_id

{% endif -%}

{% if var('snowplow__enable_ua') -%}
{% if var('snowplow__enable_ua', false) -%}

left join {{ ref('snowplow_web_pv_ua_parser') }} ua
on ev.page_view_id = ua.page_view_id

{% endif -%}

{% if var('snowplow__enable_yauaa') -%}
{% if var('snowplow__enable_yauaa', false) -%}

left join {{ ref('snowplow_web_pv_yauaa') }} ya
on ev.page_view_id = ya.page_view_id
Expand Down
2 changes: 1 addition & 1 deletion models/page_views/scratch/default/snowplow_web_pv_iab.sql
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config(
sort='page_view_id',
dist='page_view_id',
enabled=(var('snowplow__enable_iab') and target.type in ['redshift', 'postgres'] | as_bool())
enabled=(var('snowplow__enable_iab', false) and target.type in ['redshift', 'postgres'] | as_bool())
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config(
sort='page_view_id',
dist='page_view_id',
enabled=(var('snowplow__enable_ua') and target.type in ['redshift', 'postgres'] | as_bool())
enabled=(var('snowplow__enable_ua', false) and target.type in ['redshift', 'postgres'] | as_bool())
)
}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
config(
sort='page_view_id',
dist='page_view_id',
enabled=(var('snowplow__enable_yauaa') and target.type in ['redshift', 'postgres'] | as_bool())
enabled=(var('snowplow__enable_yauaa', false) and target.type in ['redshift', 'postgres'] | as_bool())
)
}}

Expand Down
12 changes: 6 additions & 6 deletions models/page_views/scratch/page_views_scratch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,9 +259,9 @@ models:
- primary-key
tests:
- unique:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_iab', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- not_null:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_iab', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- name: snowplow_web_pv_ua_parser
description: '{{ doc("table_pv_ua_parser") }}'
columns:
Expand All @@ -271,9 +271,9 @@ models:
- primary-key
tests:
- unique:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_ua', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- not_null:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_ua', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- name: snowplow_web_pv_yauaa
description: '{{ doc("table_pv_yauaa") }}'
columns:
Expand All @@ -283,9 +283,9 @@ models:
- primary-key
tests:
- unique:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_yauaa', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- not_null:
enabled: "{{ target.type in ['redshift', 'postgres'] | as_bool() }}"
enabled: "{{ var('snowplow__enable_yauaa', false) and target.type in ['redshift', 'postgres'] | as_bool() }}"
- name: snowplow_web_pv_engaged_time
description: '{{ doc("table_pv_engaged_time") }}'
columns:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ select
-- optional fields, only populated if enabled.

-- iab enrichment fields: set iab variable to true to enable
{% if var('snowplow__enable_iab') %}
{% if var('snowplow__enable_iab', false) %}

ev.contexts_com_iab_snowplow_spiders_and_robots_1[0]:category::VARCHAR AS category,
ev.contexts_com_iab_snowplow_spiders_and_robots_1[0]:primaryImpact::VARCHAR AS primary_impact,
Expand All @@ -96,7 +96,7 @@ select
{% endif %}

-- ua parser enrichment fields: set ua_parser variable to true to enable
{% if var('snowplow__enable_ua') %}
{% if var('snowplow__enable_ua', false) %}

ev.contexts_com_snowplowanalytics_snowplow_ua_parser_context_1[0]:useragentFamily::VARCHAR AS useragent_family,
ev.contexts_com_snowplowanalytics_snowplow_ua_parser_context_1[0]:useragentMajor::VARCHAR AS useragent_major,
Expand Down Expand Up @@ -129,7 +129,7 @@ select
{% endif %}

-- yauaa enrichment fields: set yauaa variable to true to enable
{% if var('snowplow__enable_yauaa') %}
{% if var('snowplow__enable_yauaa', false) %}

ev.contexts_nl_basjes_yauaa_context_1[0]:deviceClass::VARCHAR AS device_class,
ev.contexts_nl_basjes_yauaa_context_1[0]:agentClass::VARCHAR AS agent_class,
Expand Down

0 comments on commit 5c32d56

Please sign in to comment.