Skip to content

Commit

Permalink
new sessionid
Browse files Browse the repository at this point in the history
  • Loading branch information
tessa-beijloos-jumbo committed Dec 16, 2024
1 parent 6368783 commit cace7e5
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions models/staging/base/base_ga4__events.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ with source as (
renamed as (
select
{{ ga4.base_select_renamed() }},
CAST(COALESCE(REGEXP_EXTRACT(select value.string_value from unnest(event_params) where key = 'ga_session_id'), r'^GS\d\.\d\.(\d+)'), NULL) AS INT64 as session_id_mp
CAST(REGEXP_EXTRACT((select value.string_value from unnest(event_params) where key = 'ga_session_id'), r'^GS\d\.\d\.(\d+)') AS INT64) as session_id_mp
from source
)

select *, replace(COALESCE(session_id, session_id_mp) as session_id) from renamed
qualify row_number() over(partition by event_date_dt, stream_id, user_pseudo_id, session_id, session_id_mp, event_name, event_timestamp, to_json_string(ARRAY(SELECT params FROM UNNEST(event_params) AS params ORDER BY key))) = 1
select * except(session_id), COALESCE(session_id, session_id_mp) as session_id from renamed
qualify row_number() over(partition by event_date_dt, stream_id, user_pseudo_id, session_id, event_name, event_timestamp, to_json_string(ARRAY(SELECT params FROM UNNEST(event_params) AS params ORDER BY key))) = 1

0 comments on commit cace7e5

Please sign in to comment.