From 5c32d5635badc7a13fccf2503686ec174452ed19 Mon Sep 17 00:00:00 2001 From: bill-warner <71764352+bill-warner@users.noreply.github.com> Date: Thu, 16 Dec 2021 21:50:57 +0000 Subject: [PATCH] Fix for warning that tests are present on disabled models --- dbt_project.yml | 9 ++++++--- .../bigquery/snowplow_web_page_views_this_run.sql | 6 +++--- .../default/snowplow_web_page_views_this_run.sql | 12 ++++++------ .../scratch/default/snowplow_web_pv_iab.sql | 2 +- .../scratch/default/snowplow_web_pv_ua_parser.sql | 2 +- .../scratch/default/snowplow_web_pv_yauaa.sql | 2 +- models/page_views/scratch/page_views_scratch.yml | 12 ++++++------ .../snowflake/snowplow_web_page_views_this_run.sql | 6 +++--- 8 files changed, 27 insertions(+), 24 deletions(-) diff --git a/dbt_project.yml b/dbt_project.yml index 5f28ce0f..af1e01b1 100644 --- a/dbt_project.yml +++ b/dbt_project.yml @@ -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 diff --git a/models/page_views/scratch/bigquery/snowplow_web_page_views_this_run.sql b/models/page_views/scratch/bigquery/snowplow_web_page_views_this_run.sql index 6de70cce..8176cded 100644 --- a/models/page_views/scratch/bigquery/snowplow_web_page_views_this_run.sql +++ b/models/page_views/scratch/bigquery/snowplow_web_page_views_this_run.sql @@ -87,7 +87,7 @@ 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'), @@ -95,7 +95,7 @@ select -- 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'), @@ -103,7 +103,7 @@ select -- 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'), diff --git a/models/page_views/scratch/default/snowplow_web_page_views_this_run.sql b/models/page_views/scratch/default/snowplow_web_page_views_this_run.sql index 3380e850..06ad9d8b 100644 --- a/models/page_views/scratch/default/snowplow_web_page_views_this_run.sql +++ b/models/page_views/scratch/default/snowplow_web_page_views_this_run.sql @@ -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, @@ -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, @@ -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, @@ -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 diff --git a/models/page_views/scratch/default/snowplow_web_pv_iab.sql b/models/page_views/scratch/default/snowplow_web_pv_iab.sql index a6b89525..d2350231 100644 --- a/models/page_views/scratch/default/snowplow_web_pv_iab.sql +++ b/models/page_views/scratch/default/snowplow_web_pv_iab.sql @@ -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()) ) }} diff --git a/models/page_views/scratch/default/snowplow_web_pv_ua_parser.sql b/models/page_views/scratch/default/snowplow_web_pv_ua_parser.sql index 57097207..608fd029 100644 --- a/models/page_views/scratch/default/snowplow_web_pv_ua_parser.sql +++ b/models/page_views/scratch/default/snowplow_web_pv_ua_parser.sql @@ -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()) ) }} diff --git a/models/page_views/scratch/default/snowplow_web_pv_yauaa.sql b/models/page_views/scratch/default/snowplow_web_pv_yauaa.sql index 4bb7de9e..ef7f851d 100644 --- a/models/page_views/scratch/default/snowplow_web_pv_yauaa.sql +++ b/models/page_views/scratch/default/snowplow_web_pv_yauaa.sql @@ -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()) ) }} diff --git a/models/page_views/scratch/page_views_scratch.yml b/models/page_views/scratch/page_views_scratch.yml index d9222aae..0d26cdc4 100644 --- a/models/page_views/scratch/page_views_scratch.yml +++ b/models/page_views/scratch/page_views_scratch.yml @@ -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: @@ -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: @@ -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: diff --git a/models/page_views/scratch/snowflake/snowplow_web_page_views_this_run.sql b/models/page_views/scratch/snowflake/snowplow_web_page_views_this_run.sql index a8e20ad9..f03ed8eb 100644 --- a/models/page_views/scratch/snowflake/snowplow_web_page_views_this_run.sql +++ b/models/page_views/scratch/snowflake/snowplow_web_page_views_this_run.sql @@ -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, @@ -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, @@ -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,