Skip to content

Commit

Permalink
Work on base_create_snowplow_events_this_run macro optimization for s…
Browse files Browse the repository at this point in the history
…park (#186)
  • Loading branch information
ilias1111 authored Oct 29, 2024
1 parent a795167 commit 3f9d9b3
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions macros/base/base_create_snowplow_events_this_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) }}
Expand Down

0 comments on commit 3f9d9b3

Please sign in to comment.