Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal: Getting rid of Neighbors in Path Queries #6125

Merged
merged 5 commits into from
Sep 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions ee/clickhouse/sql/paths/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
conversion_time,
event_in_session_index,
concat(toString(event_in_session_index), '_', path) as path_key,
if(event_in_session_index > 1, neighbor(path_key, -1), null) AS last_path_key,
if(event_in_session_index > 1, concat(toString(event_in_session_index-1), '_', prev_path), null) AS last_path_key,
path_dropoff_key
FROM (

SELECT person_id
, joined_path_tuple.1 as path
, joined_path_tuple.2 as conversion_time
, joined_path_tuple.3 as prev_path
, event_in_session_index
, session_index
, arrayPopFront(arrayPushBack(path_basic, '')) as path_basic_0
Expand All @@ -19,7 +20,7 @@
, arrayFilter((x,y)->y, path_basic, mapping) as compact_path
{target_clause}
, arrayDifference(limited_timings) as timings_diff
, arrayZip(limited_path, timings_diff) as limited_path_timings
, arrayZip(limited_path, timings_diff, arrayPopBack(arrayPushFront(limited_path, ''))) as limited_path_timings
, concat(toString(length(limited_path)), '_', limited_path[-1]) as path_dropoff_key /* last path item */
FROM (
SELECT person_id
Expand All @@ -34,14 +35,11 @@
groupArray(path_item) as paths
FROM ({path_event_query})
GROUP BY person_id
ORDER BY person_id
)
/* this array join splits paths for a single personID per session */
ARRAY JOIN session_paths AS path_time_tuple, arrayEnumerate(session_paths) AS session_index
)
ARRAY JOIN limited_path_timings AS joined_path_tuple, arrayEnumerate(limited_path_timings) AS event_in_session_index
{boundary_event_filter}
ORDER BY person_id, session_index, event_in_session_index
)

"""