@@ -8,28 +8,28 @@ module.exports = (params) => {
88with segment_events_combined as (
99-- combine page and track tables into a full events table
1010select
11- " timestamp" ,
11+ track_events. timestamp,
1212 user_id,
1313 anonymous_id,
1414 track_id,
1515 null as page_id
1616from
17- ${ params . segmentSchema , ctx . ref ( "segment_track_events" ) }
17+ ${ params . segmentSchema , ctx . ref ( "segment_track_events" ) } as track_events
1818union all
1919select
20- " timestamp" ,
20+ page_events. timestamp,
2121 user_id,
2222 anonymous_id,
2323 null as track_id,
2424 page_id
2525from
26- ${ params . segmentSchema , ctx . ref ( "segment_page_events" ) }
26+ ${ params . segmentSchema , ctx . ref ( "segment_page_events" ) } as page_events
2727),
2828
2929segment_events_mapped as (
3030-- map anonymous_id to user_id (where possible)
3131select
32- " timestamp" ,
32+ segment_events_combined. timestamp,
3333 coalesce(
3434 segment_events_combined.user_id,
3535 segment_user_anonymous_map.user_id,
4949 *,
5050 coalesce(
5151 (
52- ${ crossdb . timestampDiff ( `millisecond` , `" timestamp" ` ,
52+ ${ crossdb . timestampDiff ( `millisecond` , `segment_events_mapped. timestamp` ,
5353 crossdb . windowFunction ( {
5454 func : "lag" ,
5555 value : "timestamp" ,
7575 value : "case when session_start_event then 1 else 0 end" ,
7676 ignore_nulls : false ,
7777 partition_fields : "user_id" ,
78- order_fields : '" timestamp" asc' ,
78+ order_fields : 'session_starts. timestamp asc' ,
7979 frame_clause : "rows between unbounded preceding and current row"
8080 } ) } as session_index
8181from
0 commit comments