-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2ed10b2
commit 9432bcd
Showing
15 changed files
with
10,512 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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,193 @@ | ||
# serializer version: 1 | ||
# name: TestCohort.test_async_deletion_of_cohort | ||
''' | ||
/* user_id:0 celery:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
SELECT count(DISTINCT person_id) | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version = NULL | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.1 | ||
''' | ||
/* user_id:0 cohort_calculation:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
INSERT INTO cohortpeople | ||
SELECT id, | ||
99999 as cohort_id, | ||
99999 as team_id, | ||
1 AS sign, | ||
1 AS version | ||
FROM | ||
(SELECT if(behavior_query.person_id = '00000000-0000-0000-0000-000000000000', person.person_id, behavior_query.person_id) AS id | ||
FROM | ||
(SELECT pdi.person_id AS person_id, | ||
countIf(timestamp > now() - INTERVAL 1 day | ||
AND timestamp < now() | ||
AND event = '$pageview' | ||
AND 1=1) > 0 AS performed_event_condition_X_level_level_0_level_1_level_0_0 | ||
FROM events e | ||
LEFT OUTER JOIN | ||
(SELECT distinct_id, | ||
argMax(person_id, version) as person_id | ||
FROM person_distinct_id2 | ||
WHERE team_id = 99999 | ||
GROUP BY distinct_id | ||
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id | ||
WHERE team_id = 99999 | ||
AND event IN ['$pageview'] | ||
AND timestamp <= now() | ||
AND timestamp >= now() - INTERVAL 1 day | ||
GROUP BY person_id) behavior_query | ||
FULL OUTER JOIN | ||
(SELECT *, | ||
id AS person_id | ||
FROM | ||
(SELECT id, | ||
argMax(properties, version) as person_props | ||
FROM person | ||
WHERE team_id = 99999 | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 SETTINGS optimize_aggregation_in_order = 1)) person ON person.person_id = behavior_query.person_id | ||
WHERE 1 = 1 | ||
AND ((((has(['something'], replaceRegexpAll(JSONExtractRaw(person_props, '$some_prop'), '^"|"$', '')))) | ||
OR ((performed_event_condition_X_level_level_0_level_1_level_0_0)))) SETTINGS optimize_aggregation_in_order = 1, | ||
join_algorithm = 'auto' ) as person | ||
UNION ALL | ||
SELECT person_id, | ||
cohort_id, | ||
team_id, | ||
-1, | ||
version | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version < 1 | ||
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1, | ||
join_algorithm = 'auto' | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.10 | ||
''' | ||
SELECT count() | ||
FROM cohortpeople | ||
WHERE cohort_id = 99999 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.11 | ||
''' | ||
/* celery:posthog.tasks.tasks.clickhouse_clear_removed_data */ | ||
SELECT DISTINCT team_id, | ||
cohort_id | ||
FROM cohortpeople | ||
WHERE (team_id = 99999 | ||
AND cohort_id = '2' | ||
AND version < '2') | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.2 | ||
''' | ||
/* user_id:0 cohort_calculation:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
SELECT count(DISTINCT person_id) | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version = 1 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.3 | ||
''' | ||
/* user_id:0 celery:posthog.tasks.calculate_cohort.clear_stale_cohort */ | ||
SELECT count() | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version < 1 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.4 | ||
''' | ||
/* user_id:0 celery:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
SELECT count(DISTINCT person_id) | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version = 1 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.5 | ||
''' | ||
/* user_id:0 cohort_calculation:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
INSERT INTO cohortpeople | ||
SELECT id, | ||
99999 as cohort_id, | ||
99999 as team_id, | ||
1 AS sign, | ||
2 AS version | ||
FROM | ||
(SELECT id | ||
FROM person | ||
WHERE team_id = 99999 | ||
AND id IN | ||
(SELECT id | ||
FROM person | ||
WHERE team_id = 99999 | ||
AND ((has(['something'], replaceRegexpAll(JSONExtractRaw(properties, '$some_prop'), '^"|"$', '')))) ) | ||
GROUP BY id | ||
HAVING max(is_deleted) = 0 | ||
AND ((has(['something'], replaceRegexpAll(JSONExtractRaw(argMax(person.properties, version), '$some_prop'), '^"|"$', '')))) SETTINGS optimize_aggregation_in_order = 1) as person | ||
UNION ALL | ||
SELECT person_id, | ||
cohort_id, | ||
team_id, | ||
-1, | ||
version | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version < 2 | ||
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1, | ||
join_algorithm = 'auto' | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.6 | ||
''' | ||
/* user_id:0 cohort_calculation:posthog.tasks.calculate_cohort.calculate_cohort_ch */ | ||
SELECT count(DISTINCT person_id) | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version = 2 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.7 | ||
''' | ||
/* user_id:0 celery:posthog.tasks.calculate_cohort.clear_stale_cohort */ | ||
SELECT count() | ||
FROM cohortpeople | ||
WHERE team_id = 99999 | ||
AND cohort_id = 99999 | ||
AND version < 2 | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.8 | ||
''' | ||
/* celery:posthog.tasks.tasks.clickhouse_clear_removed_data */ | ||
SELECT DISTINCT team_id, | ||
cohort_id | ||
FROM cohortpeople | ||
WHERE (team_id = 99999 | ||
AND cohort_id = '2' | ||
AND version < '2') | ||
''' | ||
# --- | ||
# name: TestCohort.test_async_deletion_of_cohort.9 | ||
''' | ||
/* celery:posthog.tasks.tasks.clickhouse_clear_removed_data */ | ||
DELETE | ||
FROM cohortpeople | ||
WHERE (team_id = 99999 | ||
AND cohort_id = '2' | ||
AND version < '2') | ||
''' | ||
# --- |
Oops, something went wrong.