Skip to content

Commit

Permalink
Fix field macro for databricks
Browse files Browse the repository at this point in the history
  • Loading branch information
matus-tomlein committed Aug 18, 2023
1 parent b419baa commit 10f3172
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
18 changes: 17 additions & 1 deletion macros/snowplow_media_player_base_events_this_run/field.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
{% endif %}
{% endmacro %}

{% macro default__field(property, col_prefix, field) %}
{% macro snowflake__field(property, col_prefix, field) %}
{% if property is string -%}
{{ property }}
{% else %}
Expand All @@ -32,3 +32,19 @@
}}
{% endif %}
{% endmacro %}

{% macro default__field(property, col_prefix, field) %}
{% if property is string -%}
{{ property }}
{% else %}
{{
property.get('relation_alias', 'a')
}}.{{
property.get('col_prefix', col_prefix)
}}{% if 'contexts_' in property.get('col_prefix', col_prefix) %}[0]{% endif %}.{{
property.get('field', field)
}}::{{
property.get('dtype', 'string')
}}
{% endif %}
{% endmacro %}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ with prep AS (
select

a.event_id,
a.contexts_com_snowplowanalytics_snowplow_web_page_1[0].id::string as page_view_id,
{{ web_or_mobile_col(
web_property={ 'field': 'id', 'col_prefix': 'contexts_com_snowplowanalytics_snowplow_web_page_1', 'dtype': 'string' },
mobile_property={ 'field': 'id', 'col_prefix': 'contexts_com_snowplowanalytics_mobile_screen_1', 'dtype': 'string' }
) }} as page_view_id,
b.session_id,
b.domain_userid,
a.user_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ with prep as (

a.event_id,
{{ web_or_mobile_col(
web_property='a.contexts_com_snowplowanalytics_snowplow_web_page_1[0]:id::varchar',
mobile_property='a.contexts_com_snowplowanalytics_mobile_screen_1[0]:id::varchar'
web_property={ 'field': 'id', 'col_prefix': 'contexts_com_snowplowanalytics_snowplow_web_page_1', 'dtype': 'varchar' },
mobile_property={ 'field': 'id', 'col_prefix': 'contexts_com_snowplowanalytics_mobile_screen_1', 'dtype': 'varchar' }
) }} as page_view_id,
b.session_id,
b.domain_userid,
Expand Down

0 comments on commit 10f3172

Please sign in to comment.