Skip to content

Commit

Permalink
More changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ilias1111 committed Sep 10, 2024
1 parent 2001efd commit 7689082
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 26 deletions.
4 changes: 2 additions & 2 deletions integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,8 @@ vars:
snowplow__session_aggregations: [{'type': 'count', 'field': "case when event_name = 'page_view' then 1 else null end", 'alias': 'agg_test'}]
snowplow__user_aggregations: [{'type': 'sum', 'field': "agg_test", 'alias': 'agg_test'}]
# add extra web fields:
snowplow__enable_browser_context: true
snowplow__enable_browser_context_2: false
snowplow__enable_browser_context: false
snowplow__enable_browser_context_2: true
# add extra mobile fields:
snowplow__enable_mobile_context: true
snowplow__enable_geolocation_context: true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ select
,end_tstamp

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then 'true base' else app_id end as app_id
{% else %}
, app_id
Expand Down Expand Up @@ -206,7 +206,7 @@ select
,useragent

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else event_id end as event_id
, case when event_id2 = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else event_id2 end as event_id2
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ select
,fatal_app_errors

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when first_event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else first_event_id end as first_event_id
, case when first_event_id2 = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff-first' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f-first' else first_event_id2 end as first_event_id2
, case when last_event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else last_event_id end as last_event_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0

select
-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id in ('1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76', '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f') then 'true base' else app_id end as app_id,
{% else %}
app_id,
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:33.286'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:43.000'
else dvce_created_tstamp end as dvce_created_tstamp,
Expand All @@ -26,7 +26,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else derived_tstamp end as derived_tstamp,
Expand All @@ -35,7 +35,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else start_tstamp end as start_tstamp,
Expand All @@ -44,7 +44,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else end_tstamp end as end_tstamp,
Expand All @@ -58,7 +58,7 @@ event_id,
session_identifier,

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then 1
when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then 2
else view_in_session_index end as view_in_session_index,
Expand All @@ -73,7 +73,7 @@ user_identifier,
stitched_user_id,

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '0e77779ebe3beec35d423f1c1952b81d69ecda6325902921c8e761856835808d'
else network_userid end as network_userid,
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ SELECT
,end_tstamp

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then 'true base' else app_id end as app_id
{% else %}
, app_id
Expand Down Expand Up @@ -216,7 +216,7 @@ SELECT
,useragent

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else event_id end as event_id
, case when event_id2 = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else event_id2 end as event_id2
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ select
,fatal_app_errors

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
, case when first_event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else first_event_id end as first_event_id
, case when first_event_id2 = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff-first' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f-first' else first_event_id2 end as first_event_id2
, case when last_event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' else last_event_id end as last_event_id
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0

select
-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id in ('1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76', '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f') then 'true base' else app_id end as app_id,
{% else %}
app_id,
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:33.286'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:43.000'
else dvce_created_tstamp end as dvce_created_tstamp,
Expand All @@ -25,7 +25,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else derived_tstamp end as derived_tstamp,
Expand All @@ -34,7 +34,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else start_tstamp end as start_tstamp,
Expand All @@ -43,7 +43,7 @@ select
{% endif %}

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '1b4b3b57-3cb7-4df2-a7fd-526afa9e3c76' then '2021-03-01 20:56:39.192'
when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '2021-02-26 10:50:47.000'
else end_tstamp end as end_tstamp,
Expand All @@ -57,7 +57,7 @@ event_id,
session_identifier,

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then 1
when event_id = 'b3eca04e-d277-45e0-9c7c-76dc7e8c16ff' then 2
else view_in_session_index end as view_in_session_index,
Expand All @@ -72,7 +72,7 @@ user_identifier,
stitched_user_id,

-- hard-coding due to non-deterministic outcome from row_number for Redshift/Postgres/databricks
{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
case when event_id = '3cfe1cd4-a20e-4fc7-952a-a5cb7f7d063f' then '0e77779ebe3beec35d423f1c1952b81d69ecda6325902921c8e761856835808d'
else network_userid end as network_userid,
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,7 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0
contexts_com_snowplowanalytics_mobile_application_1,
contexts_com_snowplowanalytics_mobile_deep_link_1,
parse_json('[{"viewport":"'||viewport||'", "documentSize":"'||documentSize||'", "resolution":"'||resolution||'", "colorDepth":"'||colorDepth||'", "devicePixelRatio":"'||devicePixelRatio||'", "cookiesEnabled":"'||cookiesEnabled||'", "online":"'||online||'", "browserLanguage":"'||browserLanguage||'","documentLanguage":"'||documentLanguage||'", "webdriver":"'||webdriver||'", "deviceMemory":"'||deviceMemory||'", "hardwareConcurrency":"'||hardwareConcurrency||'", "tabId":"'||tabId||'"}]' ) as contexts_com_snowplowanalytics_snowplow_browser_context_1,
parse_json('[{"viewport":"'||viewport||'", "documentSize":"'||documentSize||'", "resolution":"'||resolution||'", "colorDepth":"'||colorDepth||'", "devicePixelRatio":"'||devicePixelRatio||'", "cookiesEnabled":"'||cookiesEnabled||'", "online":"'||online||'", "browserLanguage":"'||browserLanguage||'","documentLanguage":"'||documentLanguage||'", "webdriver":"'||webdriver||'", "deviceMemory":"'||deviceMemory||'", "hardwareConcurrency":"'||hardwareConcurrency||'", "tabId":"'||tabId||'"}]' ) as contexts_com_snowplowanalytics_snowplow_browser_context_2,
parse_json('[{"deviceManufacturer":"'||deviceManufacturer||'", "deviceModel":"'||deviceModel||'", "osType":"'||osType||'", "osVersion":"'||osVersion||'", "androidIdfa":"'||androidIdfa||'", "appleIdfa":"'||appleIdfa||'", "appleIdfv":"'||appleIdfv||'", "carrier":"'||carrier||'", "openIdfa":"'||openIdfa||'", "networkTechnology":"'||networkTechnology||'", "networkType":"'||networkType||'", "physicalMemory":"'||physicalMemory||'", "systemAvailableMemory":"'||systemAvailableMemory||'", "appAvailableMemory":"'||appAvailableMemory||'", "batteryLevel":"'||batteryLevel||'", "batteryState":"'||batteryState||'", "lowPowerMode":"'||lowPowerMode||'", "availableStorage":"'||availableStorage||'", "isPortrait":"'||isPortrait||'", "totalStorage":"'||totalStorage||'", "resolution":"'||resolution2||'", "scale":"'||scale||'", "language":"'||language||'", "appSetId":"'||appSetId||'", "appSetIdScope":"'||appSetIdScope||'"}]' ) as contexts_com_snowplowanalytics_snowplow_mobile_context_1,
parse_json('[{"id":"'||id2||'", "name":"'||name2||'", "activity":"'||activity||'", "fragment":"'||fragment||'", "topViewController":"'||topViewController||'", "type":"'||type2||'", "viewController":"'||viewController||'"}]' ) as contexts_com_snowplowanalytics_mobile_screen_1,
object_construct('message', message,'programmingLanguage', programmingLanguage, 'className', className, 'exceptionName', exceptionName, 'isFatal', isFatal, 'lineNumber', lineNumber, 'stackTrace', stackTrace, 'threadId', threadId, 'threadName', threadName) as unstruct_event_com_snowplowanalytics_snowplow_application_error_1
Expand Down
2 changes: 1 addition & 1 deletion macros/field_extractions/get_browser_context_fields.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0
{%- endmacro -%}

{% macro postgres__get_browser_context_fields() %}
{% if var('snowplow__enable_browser_context', false) %}
{% if var('snowplow__enable_browser_context', false) or var('snowplow__enable_browser_context_2', false) %}
{% else %}
, cast(null as {{ snowplow_utils.type_max_string() }}) as browser__viewport
, cast(null as {{ snowplow_utils.type_max_string() }}) as browser__document_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ from base_query
)

SELECT *
{% if target.type in ['bigquery','postgres'] and var('snowplow__enable_browser_context', false) and var('snowplow__enable_browser_context_2', false) %}
{% if target.type in ['bigquery','postgres', 'redshift'] and var('snowplow__enable_browser_context', false) and var('snowplow__enable_browser_context_2', false) %}

, coalesce(browser1__viewport, browser2__viewport) AS browser__viewport
, coalesce(browser1__document_size, browser2__document_size ) AS browser__document_size
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ select
e.collector_tstamp,
e.derived_tstamp,

{% if target.type in ['redshift', 'postgres', 'databricks', 'bigquery'] -%}
{% if target.type in ['redshift', 'postgres', 'databricks'] -%}
CURRENT_TIMESTAMP as model_tstamp,
{% else %}
{{ snowplow_utils.current_timestamp_in_utc() }} as model_tstamp,
Expand Down
2 changes: 1 addition & 1 deletion models/views/scratch/snowplow_unified_views_this_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ with prep as (
{{ snowplow_unified.web_only_fields('ev') }}
, {{ snowplow_unified.content_group_query() }} as content_group
, coalesce(
{% if var('snowplow__enable_browser_context') %}
{% if var('snowplow__enable_browser_context') or var('snowplow__enable_browser_context_2') %}
cast(ev.browser__color_depth as {{ dbt.type_string() }}),
{% else %}
ev.br_colordepth,
Expand Down

0 comments on commit 7689082

Please sign in to comment.