Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release/snowplow-media-player/0.9.2 #85

Merged
merged 2 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
snowplow-media-player 0.9.2 (2024-12-10)
---------------------------------------
## Summary
This feature release introduces dynamic aggregation for passthrough fields in ad_views, allowing greater flexibility in managing session-level analytics.

## Features

**- Dynamic Aggregation for Passthrough Fields:**
Introduced the ability to apply optional aggregation logic (e.g., MAX, MIN) to passthrough fields in the media_player_media_ad_views model. This feature prevents cardinality violations while maintaining compatibility for non-aggregation fields.
**Example configuration:**
```yaml
snowplow__ad_views_passthroughs: [
"v_collector",
{"sql": "v_tracker || app_id", "alias": "tracker_app_id", "agg": "max"},
{"sql": "v_collector", "alias": "v_collector_alias", "agg": "min"}
]
```

This is an optional feature and can be implemented if required by your use case.

## Upgrading

Update the snowplow-media-player version in your packages.yml file.

snowplow-media-player 0.9.1 (2024-10-23)
---------------------------------------
## Summary
Expand Down
2 changes: 1 addition & 1 deletion dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'snowplow_media_player'
version: '0.9.1'
version: '0.9.2'
config-version: 2

require-dbt-version: ['>=1.4.0', '<2.0.0']
Expand Down
19 changes: 16 additions & 3 deletions integration_tests/.scripts/integration_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ for db in ${DATABASES[@]}; do

eval "dbt run --target $db --vars '{snowplow__enable_youtube: false, snowplow__enable_whatwg_media: false, snowplow__enable_whatwg_video: false, snowplow__enable_media_player_v1: false}'" || exit 1;



echo "Snowplow media player integration tests: Execute models - run 1/6"

eval "dbt run --target $db --full-refresh --vars '{snowplow__allow_refresh: true}'" || exit 1;
Expand All @@ -69,6 +67,21 @@ for db in ${DATABASES[@]}; do

eval "dbt test --target $db" || exit 1;

echo "Snowplow media player integration tests: Testing ad views passthrough - mixed configuration"
eval "dbt run --select +snowplow_media_player_media_ad_views_this_run --target $db --full-refresh --vars '{
snowplow__allow_refresh: true,
snowplow__enable_media_ad: true,
snowplow__backfill_limit_days: 999,
snowplow__ad_views_passthroughs: [
\"v_collector\",
{\"sql\": \"v_tracker || app_id\", \"alias\": \"tracker_app_id\", \"agg\": \"max\"},
{\"sql\": \"v_tracker || app_id\", \"alias\": \"tracker_app_id_1\", \"agg\": \"min\"},
{\"sql\": \"v_collector\", \"alias\": \"tracker_app_id_2\", \"agg\": \"min\"}
]
}'" || exit 1;

eval "dbt test --target $db --select snowplow_media_player_media_ad_views_this_run" || exit 1;

echo "Snowplow media player integration tests: All tests passed"

done
done
2 changes: 1 addition & 1 deletion integration_tests/dbt_project.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: 'snowplow_media_player_integration_tests'
version: '0.9.1'
version: '0.9.2'
config-version: 2

profile: 'integration_tests'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,39 @@ events_this_run as (
,ev.media_ad_break__break_id as ad_break_id
,ev.media_ad__ad_id as ad_id


{%- set non_agg_identifiers = [] -%}
{%- for identifier in var('snowplow__ad_views_passthroughs', []) -%}
{%- if identifier is not mapping or 'agg' not in identifier -%}
{%- do non_agg_identifiers.append(identifier) -%}
{%- endif -%}
{%- endfor -%}


{%- if var('snowplow__ad_views_passthroughs', []) -%}
{%- set passthrough_names = [] -%}
{%- set agg_identifiers = [] -%}

{%- for identifier in var('snowplow__ad_views_passthroughs', []) %}
{# Check if it is a simple column or a sql+alias #}
{%- if identifier is mapping -%}
,{{identifier['sql']}} as {{identifier['alias']}}
{%- do passthrough_names.append(identifier['alias']) -%}
{%- else -%}
,ev.{{identifier}}
{%- do passthrough_names.append(identifier) -%}
{%- endif -%}
{# Check if it is a mapping with no agg attribute #}
{%- if identifier is mapping and 'agg' not in identifier -%}
,{{identifier['sql']}} as {{identifier['alias']}}
{%- do passthrough_names.append(identifier['alias']) -%}

{# Check if it is a mapping with agg attribute #}
{%- elif identifier is mapping and 'agg' in identifier -%}
{%- do agg_identifiers.append(identifier) -%}

{# Handle simple column names #}
{%- else -%}
,ev.{{identifier}}
{%- do passthrough_names.append(identifier) -%}
{%- endif -%}
{% endfor -%}

{# Add aggregated columns after the main selection #}
{%- for agg_col in agg_identifiers %}
,{{agg_col['agg']}}({{agg_col['sql']}}) as {{agg_col['alias']}}
{% endfor -%}
{%- endif %}

Expand All @@ -81,7 +103,7 @@ events_this_run as (
,{{ snowplow_utils.get_string_agg('original_session_identifier', 'ev', is_distinct=True) }} as domain_sessionid_array

from events_this_run as ev
{{ dbt_utils.group_by(n=9+(var('snowplow__ad_views_passthroughs', [])|length)) }}
{{ dbt_utils.group_by(n=9+non_agg_identifiers|length) }}


)
Expand Down Expand Up @@ -123,6 +145,10 @@ select
{%- for col in passthrough_names %}
, p.{{col}}
{%- endfor -%}
{%- for agg_col in agg_identifiers %}
, p.{{agg_col['alias']}}
{%- endfor -%}

{%- endif %}

from prep as p
Loading