Skip to content

Commit

Permalink
Fix error on Redshift due to base_events_this_run using the transacti…
Browse files Browse the repository at this point in the history
…on_id as partition key event if transactions are disabled (close #51)
  • Loading branch information
matus-tomlein committed Apr 5, 2024
1 parent be70194 commit 321a908
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
11 changes: 11 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
snowplow-ecommerce 0.8.2 (2024-04-05)
---------------------------------------
## Summary
This release fixes a bug on Redshift that caused an error in case transactions were disabled.

## Fixes
- Fix error on Redshift due to base_events_this_run using the transaction_id as partition key event if transactions are disabled (#51)

## Upgrading
To upgrade simply bump the snowplow-ecommerce version in your `packages.yml` file.

snowplow-ecommerce 0.8.1 (2024-03-18)
---------------------------------------
## Summary
Expand Down
14 changes: 10 additions & 4 deletions models/base/scratch/snowplow_ecommerce_base_events_this_run.sql
Original file line number Diff line number Diff line change
Expand Up @@ -118,22 +118,28 @@ field_extract as (

where 1 = 1
and {{ snowplow_ecommerce.event_name_filter(var("snowplow__ecommerce_event_names", "['snowplow_ecommerce_action']")) }}
),
)


transaction_dedupe as (
select
{% if not var('snowplow__disable_ecommerce_transactions', false) -%}
, transaction_dedupe as (
select
*
, case when ecommerce_action_type != 'transaction' or ecommerce_action_type is null then 1 else row_number() over (partition by domain_sessionid, transaction_id order by derived_tstamp) end AS transaction_id_index
from
field_extract

)
{%- endif %}

select
select
*
, dense_rank() over (partition by domain_sessionid order by derived_tstamp) AS event_in_session_index
from
{% if var('snowplow__disable_ecommerce_transactions', false) -%}
field_extract
{%- else -%}
transaction_dedupe
where
transaction_id_index = 1
{%- endif %}

0 comments on commit 321a908

Please sign in to comment.