-
Notifications
You must be signed in to change notification settings - Fork 2k
feat(analytics-platform): Redesign sessions v3 for better partition pruning and indexing #39092
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a3bcdc4
Redesign sessions v3 for better partition pruning and indexing
robbie-c e193ec9
Don't use = to check whether element in set
robbie-c 2f78f49
Fix wrapping in toTimeZone
robbie-c d4247fd
Update query snapshots
github-actions[bot] 2a6d305
Update query snapshots
github-actions[bot] 818d21b
Exclude session_timestamp from properties
robbie-c 2c71c4c
Remove redundant test
robbie-c f555f8d
Remove extra comma
robbie-c 7085f11
Add snapshots to v3 session tests
robbie-c aaa5b2b
Fix duplicate session id in group by
robbie-c 918a13a
Replace numbers in session tests
robbie-c cc6df14
Update query snapshots
github-actions[bot] 5c7c11b
Update query snapshots
github-actions[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
175 changes: 175 additions & 0 deletions
175
posthog/clickhouse/test/__snapshots__/test_raw_sessions_v3_model.ambr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# serializer version: 1 | ||
# name: TestRawSessionsModel.test_ad_ids_map_and_set | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_autocapture_does_not_set_attribution_when_pageview_present | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_autocapture_does_set_attribution_when_only_event | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_channel_type_properties | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_counts_pageviews_autocaptures_and_events | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_handles_different_distinct_id_across_same_session | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_handles_entry_and_exit_urls | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_handles_initial_utm_properties | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_it_creates_session_when_creating_event | ||
''' | ||
|
||
select session_id_v7, | ||
team_id | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_lookup_feature_flag | ||
''' | ||
|
||
select session_id_v7, | ||
has(flag_values['$feature/flag_string'], 'f1_a') as has_f1_a, | ||
has(flag_values['$feature/flag_string'], 'f1_b') as has_f1_b, | ||
has(flag_values['$feature/flag_string'], 'f1_c') as has_f1_c | ||
from raw_sessions_v3_v | ||
where team_id = 99999 | ||
ORDER BY session_id_v7 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_max_inserted_at | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_select_from_sessions | ||
''' | ||
|
||
SELECT session_id_v7, | ||
team_id, | ||
min_timestamp, | ||
max_timestamp, | ||
urls | ||
FROM raw_sessions_v3 | ||
WHERE session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_select_from_sessions_mv | ||
''' | ||
|
||
SELECT session_id_v7, | ||
team_id, | ||
min_timestamp, | ||
max_timestamp, | ||
urls | ||
FROM raw_sessions_v3_mv | ||
WHERE session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_separates_sessions_across_same_user | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_separates_sessions_across_same_user.1 | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_separates_sessions_across_same_user.2 | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_store_all_feature_flag_values | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- | ||
# name: TestRawSessionsModel.test_tracks_all_distinct_ids | ||
''' | ||
|
||
select * | ||
from raw_sessions_v3_v | ||
where session_id_v7 = toUInt128(toUUID('00000000-0000-0000-0000-000000000000')) | ||
AND team_id = 99999 | ||
''' | ||
# --- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.