-
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
57da9aa
commit e1669d9
Showing
4 changed files
with
4,091 additions
and
0 deletions.
There are no files selected for viewing
55 changes: 55 additions & 0 deletions
55
ee/clickhouse/queries/test/__snapshots__/test_groups_join_query.ambr
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,55 @@ | ||
# serializer version: 1 | ||
# name: test_groups_join_query_filtering | ||
tuple( | ||
''' | ||
|
||
LEFT JOIN ( | ||
SELECT | ||
group_key, | ||
argMax(group_properties, _timestamp) AS group_properties_0 | ||
FROM groups | ||
WHERE team_id = %(team_id)s AND group_type_index = %(group_index_0)s | ||
GROUP BY group_key | ||
) groups_0 | ||
ON "$group_0" == groups_0.group_key | ||
|
||
''', | ||
dict({ | ||
'group_index_0': 0, | ||
'team_id': 2, | ||
}), | ||
) | ||
# --- | ||
# name: test_groups_join_query_filtering_with_custom_key_names | ||
tuple( | ||
''' | ||
|
||
LEFT JOIN ( | ||
SELECT | ||
group_key, | ||
argMax(group_properties, _timestamp) AS group_properties_0 | ||
FROM groups | ||
WHERE team_id = %(team_id)s AND group_type_index = %(group_index_0)s | ||
GROUP BY group_key | ||
) groups_0 | ||
ON call_me_industry == groups_0.group_key | ||
|
||
|
||
LEFT JOIN ( | ||
SELECT | ||
group_key, | ||
argMax(group_properties, _timestamp) AS group_properties_2 | ||
FROM groups | ||
WHERE team_id = %(team_id)s AND group_type_index = %(group_index_2)s | ||
GROUP BY group_key | ||
) groups_2 | ||
ON call_me_industry == groups_2.group_key | ||
|
||
''', | ||
dict({ | ||
'group_index_0': 0, | ||
'group_index_2': 2, | ||
'team_id': 2, | ||
}), | ||
) | ||
# --- |
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
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 |
---|---|---|
|
@@ -2055,3 +2055,211 @@ | |
OFFSET 10000 | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db | ||
''' | ||
WITH target_person_ids AS | ||
(SELECT team_id, | ||
person_id | ||
FROM posthog_persondistinctid | ||
WHERE team_id = 2 | ||
AND distinct_id = ANY('{example_id,random}') ), | ||
existing_overrides AS | ||
(SELECT team_id, | ||
person_id, | ||
feature_flag_key, | ||
hash_key | ||
FROM posthog_featureflaghashkeyoverride | ||
WHERE team_id = 2 | ||
AND person_id IN | ||
(SELECT person_id | ||
FROM target_person_ids) ) | ||
SELECT key | ||
FROM posthog_featureflag | ||
WHERE team_id = 2 | ||
AND ensure_experience_continuity = TRUE | ||
AND active = TRUE | ||
AND deleted = FALSE | ||
AND key NOT IN | ||
(SELECT feature_flag_key | ||
FROM existing_overrides) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.1 | ||
''' | ||
WITH target_person_ids AS | ||
(SELECT team_id, | ||
person_id | ||
FROM posthog_persondistinctid | ||
WHERE team_id = 2 | ||
AND distinct_id = ANY('{example_id,random}') ), | ||
existing_overrides AS | ||
(SELECT team_id, | ||
person_id, | ||
feature_flag_key, | ||
hash_key | ||
FROM posthog_featureflaghashkeyoverride | ||
WHERE team_id = 2 | ||
AND person_id IN | ||
(SELECT person_id | ||
FROM target_person_ids) ), | ||
flags_to_override AS | ||
(SELECT key | ||
FROM posthog_featureflag | ||
WHERE team_id = 2 | ||
AND ensure_experience_continuity = TRUE | ||
AND active = TRUE | ||
AND deleted = FALSE | ||
AND key NOT IN | ||
(SELECT feature_flag_key | ||
FROM existing_overrides) ) | ||
INSERT INTO posthog_featureflaghashkeyoverride (team_id, person_id, feature_flag_key, hash_key) | ||
SELECT team_id, | ||
person_id, | ||
key, | ||
'random' | ||
FROM flags_to_override, | ||
target_person_ids | ||
WHERE EXISTS | ||
(SELECT 1 | ||
FROM posthog_person | ||
WHERE id = person_id | ||
AND team_id = 2) ON CONFLICT DO NOTHING | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.2 | ||
''' | ||
SELECT "posthog_persondistinctid"."person_id", | ||
"posthog_persondistinctid"."distinct_id" | ||
FROM "posthog_persondistinctid" | ||
WHERE ("posthog_persondistinctid"."distinct_id" IN ('example_id', | ||
'random') | ||
AND "posthog_persondistinctid"."team_id" = 2) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.3 | ||
''' | ||
SELECT "posthog_featureflaghashkeyoverride"."feature_flag_key", | ||
"posthog_featureflaghashkeyoverride"."hash_key", | ||
"posthog_featureflaghashkeyoverride"."person_id" | ||
FROM "posthog_featureflaghashkeyoverride" | ||
WHERE ("posthog_featureflaghashkeyoverride"."person_id" IN (1, | ||
2, | ||
3, | ||
4, | ||
5 /* ... */) | ||
AND "posthog_featureflaghashkeyoverride"."team_id" = 2) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.4 | ||
''' | ||
SELECT (("posthog_person"."properties" -> 'email') = '"[email protected]"'::jsonb | ||
AND "posthog_person"."properties" ? 'email' | ||
AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", | ||
(true) AS "flag_X_condition_0" | ||
FROM "posthog_person" | ||
INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") | ||
WHERE ("posthog_persondistinctid"."distinct_id" = 'example_id' | ||
AND "posthog_persondistinctid"."team_id" = 2 | ||
AND "posthog_person"."team_id" = 2) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.5 | ||
''' | ||
WITH target_person_ids AS | ||
(SELECT team_id, | ||
person_id | ||
FROM posthog_persondistinctid | ||
WHERE team_id = 2 | ||
AND distinct_id = ANY('{example_id,random}') ), | ||
existing_overrides AS | ||
(SELECT team_id, | ||
person_id, | ||
feature_flag_key, | ||
hash_key | ||
FROM posthog_featureflaghashkeyoverride | ||
WHERE team_id = 2 | ||
AND person_id IN | ||
(SELECT person_id | ||
FROM target_person_ids) ) | ||
SELECT key | ||
FROM posthog_featureflag | ||
WHERE team_id = 2 | ||
AND ensure_experience_continuity = TRUE | ||
AND active = TRUE | ||
AND deleted = FALSE | ||
AND key NOT IN | ||
(SELECT feature_flag_key | ||
FROM existing_overrides) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.6 | ||
''' | ||
SELECT "posthog_persondistinctid"."person_id", | ||
"posthog_persondistinctid"."distinct_id" | ||
FROM "posthog_persondistinctid" | ||
WHERE ("posthog_persondistinctid"."distinct_id" IN ('example_id', | ||
'random') | ||
AND "posthog_persondistinctid"."team_id" = 2) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_experience_continuity_working_slow_db.7 | ||
''' | ||
SELECT "posthog_persondistinctid"."person_id", | ||
"posthog_persondistinctid"."distinct_id" | ||
FROM "posthog_persondistinctid" | ||
WHERE ("posthog_persondistinctid"."distinct_id" IN ('random') | ||
AND "posthog_persondistinctid"."team_id" = 2) | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db | ||
''' | ||
SELECT "posthog_grouptypemapping"."id", | ||
"posthog_grouptypemapping"."team_id", | ||
"posthog_grouptypemapping"."group_type", | ||
"posthog_grouptypemapping"."group_type_index", | ||
"posthog_grouptypemapping"."name_singular", | ||
"posthog_grouptypemapping"."name_plural" | ||
FROM "posthog_grouptypemapping" | ||
WHERE "posthog_grouptypemapping"."team_id" = 2 | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db.1 | ||
''' | ||
SELECT "posthog_grouptypemapping"."id", | ||
"posthog_grouptypemapping"."team_id", | ||
"posthog_grouptypemapping"."group_type", | ||
"posthog_grouptypemapping"."group_type_index", | ||
"posthog_grouptypemapping"."name_singular", | ||
"posthog_grouptypemapping"."name_plural" | ||
FROM "posthog_grouptypemapping" | ||
WHERE "posthog_grouptypemapping"."team_id" = 2 | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_group_properties_and_slow_db.2 | ||
''' | ||
SELECT "posthog_grouptypemapping"."id", | ||
"posthog_grouptypemapping"."team_id", | ||
"posthog_grouptypemapping"."group_type", | ||
"posthog_grouptypemapping"."group_type_index", | ||
"posthog_grouptypemapping"."name_singular", | ||
"posthog_grouptypemapping"."name_plural" | ||
FROM "posthog_grouptypemapping" | ||
WHERE "posthog_grouptypemapping"."team_id" = 2 | ||
''' | ||
# --- | ||
# name: TestResiliency.test_feature_flags_v3_with_slow_db_doesnt_try_to_compute_conditions_again | ||
''' | ||
SELECT (("posthog_person"."properties" -> 'email') = '"[email protected]"'::jsonb | ||
AND "posthog_person"."properties" ? 'email' | ||
AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", | ||
(("posthog_person"."properties" -> 'email') = '"[email protected]"'::jsonb | ||
AND "posthog_person"."properties" ? 'email' | ||
AND NOT (("posthog_person"."properties" -> 'email') = 'null'::jsonb)) AS "flag_X_condition_0", | ||
(true) AS "flag_X_condition_0" | ||
FROM "posthog_person" | ||
INNER JOIN "posthog_persondistinctid" ON ("posthog_person"."id" = "posthog_persondistinctid"."person_id") | ||
WHERE ("posthog_persondistinctid"."distinct_id" = 'example_id' | ||
AND "posthog_persondistinctid"."team_id" = 2 | ||
AND "posthog_person"."team_id" = 2) | ||
''' | ||
# --- |
Oops, something went wrong.