diff --git a/macros/base/base_create_snowplow_events_this_run.sql b/macros/base/base_create_snowplow_events_this_run.sql index 6e945abf..eb0319a4 100644 --- a/macros/base/base_create_snowplow_events_this_run.sql +++ b/macros/base/base_create_snowplow_events_this_run.sql @@ -282,19 +282,20 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 NULL ) as session_identifier, {%- endif %} - e.*, - row_number() over (partition by event_id order by {{ session_timestamp }}, dvce_created_tstamp) as event_id_dedupe_index - + e.* from {{ snowplow_events }} e + WHERE e.{{ session_timestamp }} >= {{ lower_limit }} + and e.{{ session_timestamp }} <= {{ upper_limit }} - ) - + ), + main_logic as ( select a.* ,b.user_identifier -- take user_identifier from manifest. This ensures only 1 domain_userid per session. {% if custom_sql %} , {{ custom_sql }} {% endif %} + ,row_number() over (partition by event_id order by {{ session_timestamp }}, dvce_created_tstamp) as event_id_dedupe_index from identified_events as a inner join {{ sessions_this_run }} as b @@ -316,8 +317,10 @@ You may obtain a copy of the Snowplow Personal and Academic License Version 1.0 {% endif %} and {{ snowplow_utils.app_id_filter(app_ids) }} - - and a.event_id_dedupe_index = 1 + ) + SELECT * + FROM main_logic + WHERE event_id_dedupe_index = 1 {% endset %} {{ return(events_this_run_query) }}