@@ -21,7 +21,6 @@ module.exports = (params) => {
2121 ...params . defaultConfig
2222 } ) . query ( ctx => `
2323
24- /* TODO: optimise this code to make it work, or enable only for incremental builds */
2524with first_and_last_page_values as (
2625select distinct
2726 session_id,
@@ -46,8 +45,6 @@ select distinct
4645 from
4746 ${ ctx . ref ( params . defaultConfig . schema , "segment_sessionized_pages" ) } as sessionized_pages
4847 )
49- /*
50- */
5148
5249select
5350 segment_sessionized_events.session_id,
@@ -62,21 +59,18 @@ select
6259 count(segment_sessionized_events.page_id) as total_pages,
6360 ${ crossdb . timestampDiff ( "millisecond" , "min(segment_sessionized_events.timestamp)" , "max(segment_sessionized_events.timestamp)" ) } as duration_millis
6461 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `) as stats` ) } ,
65- /* See TODO at start of script */
6662 -- first values in the session for page fields
6763 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `struct(\n ` ) }
6864 ${ Object . entries ( { ...segmentCommon . PAGE_FIELDS , ...customPageFieldsObj } ) . map (
6965 ( [ key , value ] ) => `first_and_last_page_values.first_${ value } ` ) . join ( ",\n " ) }
7066 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `) as first_page_values` ) } ,
71- /*
7267 -- last values in the session for page fields
7368 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `struct(\n ` ) }
7469 ${ Object . entries ( { ...segmentCommon . PAGE_FIELDS , ...customPageFieldsObj } ) . map (
7570 ( [ key , value ] ) => `first_and_last_page_values.last_${ value } ` ) . join ( ",\n " ) }
7671 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `) as last_page_values` ) }
77- */
7872 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `-- repeated array of records
79- /*,*/ array_agg(
73+ , array_agg(
8074 struct(
8175 segment_sessionized_events.timestamp,
8276 struct(
@@ -95,22 +89,19 @@ select
9589 ) as records` ) }
9690from
9791 ${ ctx . ref ( params . defaultConfig . schema , "segment_sessionized_events" ) } as segment_sessionized_events
98- /* See TODO at start of script */
9992 left join first_and_last_page_values
10093 using(session_id)
101- /**/
10294 ${ ctx . when ( global . session . config . warehouse == "bigquery" , `
10395 left join ${ ctx . ref ( params . defaultConfig . schema , "segment_sessionized_pages" ) } as segment_sessionized_pages
10496 using(page_id)
10597 left join ${ ctx . ref ( params . defaultConfig . schema , "segment_sessionized_tracks" ) } as segment_sessionized_tracks
10698 using(track_id)` ) }
10799group by
108100 session_id, session_index, user_id
109- /* See TODO at start of script */
110101 ${ Object . entries ( { ...segmentCommon . PAGE_FIELDS , ...customPageFieldsObj } ) . map (
111102 ( [ key , value ] ) => `, first_${ value } ` ) . join ( " " ) }
112- /* ${ Object . entries ( { ...segmentCommon . PAGE_FIELDS , ...customPageFieldsObj } ) . map (
103+ ${ Object . entries ( { ...segmentCommon . PAGE_FIELDS , ...customPageFieldsObj } ) . map (
113104 ( [ key , value ] ) => `, last_${ value } ` ) . join ( " " ) }
114- */
105+
115106` )
116107}
0 commit comments