-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial transaction dedup concept * first test * working copy * performance optimization * docs * code cleanup
- Loading branch information
Showing
2 changed files
with
38 additions
and
1 deletion.
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
27 changes: 27 additions & 0 deletions
27
models/staging/recommended_events/stg_ga4__event_purchase_deduplicated.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,27 @@ | ||
{% if not flags.FULL_REFRESH %} | ||
{% set partitions_to_query = ['current_date'] %} | ||
{% for i in range(var('static_incremental_days', 1)) %} | ||
{% set partitions_to_query = partitions_to_query.append('date_sub(current_date, interval ' + (i+1)|string + ' day)') %} | ||
{% endfor %} | ||
{% endif %} | ||
|
||
{{ | ||
config( | ||
enabled = false, | ||
) | ||
}} | ||
with purch as ( | ||
select | ||
* | ||
from {{ref('stg_ga4__event_purchase')}} | ||
{% if not flags.FULL_REFRESH %} | ||
where event_date_dt in ({{ partitions_to_query | join(',') }}) | ||
{% endif %} | ||
qualify row_number() over( | ||
partition by transaction_id | ||
order by event_timestamp | ||
) = 1 | ||
) | ||
select | ||
* | ||
from purch |