Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dgitis committed Oct 18, 2023
1 parent 0eb9034 commit a7f55aa
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,11 @@ with purch as (
{% if not flags.FULL_REFRESH %}
where event_date_dt in ({{ partitions_to_query | join(',') }})
{% endif %}
)
, dedup as (
/* this is intended to be the maximally performant MVP for transaction deduplication
it is possible that you may want to roll up various purchase parameters and not just event_key where later events contain late-arriving parameters
in cases like this, use this model as a template and make your customizations in your project */
select distinct
first_value(event_key ignore nulls) over (transaction_window) as event_key
from purch
window transaction_window as (
partition by transaction_id
order by
event_timestamp asc rows between unbounded preceding
and unbounded following
)
qualify row_number() over(
partition by transaction_id
order by event_timestamp
) = 1
)
select
purch.*
from dedup
left join purch on dedup.event_key = purch.event_key
*
from purch

0 comments on commit a7f55aa

Please sign in to comment.