-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify base events this run (close #60)
- Loading branch information
1 parent
bcd6e3a
commit 68bcc26
Showing
31 changed files
with
602 additions
and
1,335 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
macros/snowplow_media_player_base_events_this_run/dtype_to_type.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{# | ||
Copyright (c) 2022-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{% macro dtype_to_type(dtype) -%} | ||
{{ return(adapter.dispatch('dtype_to_type', 'snowplow_media_player')(dtype)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__dtype_to_type(dtype) -%} | ||
|
||
{%- if 'string' in dtype -%} | ||
{{ type_string() }} | ||
|
||
{%- elif 'integer' in dtype -%} | ||
{{ type_int() }} | ||
|
||
{%- elif 'number' in dtype -%} | ||
{{ type_numeric() }} | ||
|
||
{%- elif 'float' in dtype -%} | ||
{{ type_float() }} | ||
|
||
{%- elif 'boolean' in dtype -%} | ||
{{ type_boolean() }} | ||
|
||
{%- else -%} | ||
{{ exceptions.raise_compiler_error(dtype ~ ' dtype is not supported, please use data type specified in schema') }} | ||
|
||
{%- endif -%} | ||
|
||
{%- endmacro %} |
39 changes: 0 additions & 39 deletions
39
macros/snowplow_media_player_base_events_this_run/field.sql
This file was deleted.
Oops, something went wrong.
18 changes: 18 additions & 0 deletions
18
macros/snowplow_media_player_base_events_this_run/field_alias.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{# | ||
Copyright (c) 2022-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{% macro field_alias(field, prefix=None) -%} | ||
{{ return(adapter.dispatch('field_alias', 'snowplow_media_player')(field, prefix)) }} | ||
{%- endmacro %} | ||
|
||
{% macro default__field_alias(field, prefix) -%} | ||
|
||
{% set alias = (prefix~'_' if prefix else '')~(snakeify_case(field.get('field'))) -%} | ||
|
||
{{ alias }} | ||
|
||
{%- endmacro %} |
23 changes: 23 additions & 0 deletions
23
macros/snowplow_media_player_base_events_this_run/get_context_fields.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{# | ||
Copyright (c) 2022-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{% macro get_context_fields(fields, enabled, context, prefix=None) %} | ||
{{ return(adapter.dispatch('get_context_fields', 'snowplow_media_player')(fields, enabled, context, prefix)) }} | ||
{% endmacro %} | ||
|
||
{% macro default__get_context_fields(fields, enabled, context, prefix) %} | ||
|
||
{%- if enabled -%} | ||
{{ get_enabled_context_fields(fields, context, prefix) }} | ||
{%- else -%} | ||
{% for f in fields %} | ||
, cast(null as {{ dtype_to_type(f.get('dtype')) }}) as {{ field_alias(f, prefix) }} | ||
{%- endfor %} | ||
|
||
{%- endif -%} | ||
|
||
{% endmacro %} |
56 changes: 56 additions & 0 deletions
56
macros/snowplow_media_player_base_events_this_run/get_enabled_context_fields.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
{# | ||
Copyright (c) 2022-present Snowplow Analytics Ltd. All rights reserved. | ||
This program is licensed to you under the Snowplow Personal and Academic License Version 1.0, | ||
and you may not use this file except in compliance with the Snowplow Personal and Academic License Version 1.0. | ||
You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 at https://docs.snowplow.io/personal-and-academic-license-1.0/ | ||
#} | ||
|
||
{% macro get_enabled_context_fields(fields, col_prefix, field_prefix) -%} | ||
{{ return(adapter.dispatch('get_enabled_context_fields')(fields, col_prefix, field_prefix)) }} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro postgres__get_enabled_context_fields(fields, col_prefix, field_prefix) -%} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro bigquery__get_enabled_context_fields(fields, col_prefix, field_prefix) -%} | ||
{% for f in fields %} | ||
, {{ snowplow_utils.get_optional_fields( | ||
enabled=true, | ||
fields=[{'field': snakeify_case(f.get('field')), 'dtype': f.get('dtype') }], | ||
col_prefix=col_prefix, | ||
relation=source('atomic', 'events'), | ||
relation_alias='ev', | ||
include_field_alias=false | ||
) }} as {{ field_alias(f, field_prefix) }} | ||
{%- endfor %} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro snowflake__get_enabled_context_fields(fields, col_prefix, field_prefix) -%} | ||
{% for f in fields %} | ||
{% set type = dtype_to_type(f.get('dtype')) %} | ||
, {{ snowplow_utils.get_field( | ||
column_name=col_prefix, | ||
field_name=f.get('field'), | ||
table_alias='ev', | ||
type=type, | ||
array_index='0' if 'contexts_' in col_prefix else none | ||
) }} as {{ field_alias(f, field_prefix) }} | ||
{%- endfor %} | ||
{%- endmacro %} | ||
|
||
|
||
{% macro spark__get_enabled_context_fields(fields, col_prefix, field_prefix) -%} | ||
{% for f in fields %} | ||
{% set type = dtype_to_type(f.get('dtype')) %} | ||
, {{ snowplow_utils.get_field( | ||
column_name=col_prefix, | ||
field_name=snakeify_case(f.get('field')), | ||
table_alias='ev', | ||
type=type, | ||
array_index='0' if 'contexts_' in col_prefix else none | ||
) }} as {{ field_alias(f, field_prefix) }} | ||
{%- endfor %} | ||
{%- endmacro %} |
23 changes: 0 additions & 23 deletions
23
macros/snowplow_media_player_base_events_this_run/media_ad_break_field.sql
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
macros/snowplow_media_player_base_events_this_run/media_ad_field.sql
This file was deleted.
Oops, something went wrong.
23 changes: 0 additions & 23 deletions
23
macros/snowplow_media_player_base_events_this_run/media_ad_quartile_event_field.sql
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 0 additions & 40 deletions
40
macros/snowplow_media_player_base_events_this_run/media_player_field.sql
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.