Skip to content

Commit

Permalink
Update query snapshots
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed Oct 11, 2024
1 parent 57da9aa commit e1669d9
Show file tree
Hide file tree
Showing 4 changed files with 4,091 additions and 0 deletions.
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,
}),
)
# ---
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,113 @@
GROUP BY prop
'''
# ---
# name: ClickhouseTestFunnelExperimentResults.test_experiment_flow_with_event_results_for_three_test_variants
'''
/* user_id:0 celery:posthog.tasks.tasks.sync_insight_caching_state */
SELECT team_id,
date_diff('second', max(timestamp), now()) AS age
FROM events
WHERE timestamp > date_sub(DAY, 3, now())
AND timestamp < now()
GROUP BY team_id
ORDER BY age;
'''
# ---
# name: ClickhouseTestFunnelExperimentResults.test_experiment_flow_with_event_results_for_three_test_variants.1
'''
/* user_id:0 request:_snapshot_ */
SELECT array(replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '')) AS value,
count(*) as count
FROM events e
WHERE team_id = 2
AND event IN ['$pageleave', '$pageview']
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
GROUP BY value
ORDER BY count DESC, value DESC
LIMIT 26
OFFSET 0
'''
# ---
# name: ClickhouseTestFunnelExperimentResults.test_experiment_flow_with_event_results_for_three_test_variants.2
'''
/* user_id:0 request:_snapshot_ */
SELECT countIf(steps = 1) step_1,
countIf(steps = 2) step_2,
avg(step_1_average_conversion_time_inner) step_1_average_conversion_time,
median(step_1_median_conversion_time_inner) step_1_median_conversion_time,
prop
FROM
(SELECT aggregation_target,
steps,
avg(step_1_conversion_time) step_1_average_conversion_time_inner,
median(step_1_conversion_time) step_1_median_conversion_time_inner ,
prop
FROM
(SELECT aggregation_target,
steps,
max(steps) over (PARTITION BY aggregation_target,
prop) as max_steps,
step_1_conversion_time ,
prop
FROM
(SELECT *,
if(latest_0 <= latest_1
AND latest_1 <= latest_0 + INTERVAL 14 DAY, 2, 1) AS steps ,
if(isNotNull(latest_1)
AND latest_1 <= latest_0 + INTERVAL 14 DAY, dateDiff('second', toDateTime(latest_0), toDateTime(latest_1)), NULL) step_1_conversion_time,
prop
FROM
(SELECT aggregation_target, timestamp, step_0,
latest_0,
step_1,
min(latest_1) over (PARTITION by aggregation_target,
prop
ORDER BY timestamp DESC ROWS BETWEEN UNBOUNDED PRECEDING AND 0 PRECEDING) latest_1 ,
if(has([[''], ['test_1'], ['test'], ['control'], ['unknown_3'], ['unknown_2'], ['unknown_1'], ['test_2']], prop), prop, ['Other']) as prop
FROM
(SELECT *,
if(notEmpty(arrayFilter(x -> notEmpty(x), prop_vals)), prop_vals, ['']) as prop
FROM
(SELECT e.timestamp as timestamp,
if(notEmpty(pdi.distinct_id), pdi.person_id, e.person_id) as aggregation_target,
if(notEmpty(pdi.distinct_id), pdi.person_id, e.person_id) as person_id,
if(event = '$pageview', 1, 0) as step_0,
if(step_0 = 1, timestamp, null) as latest_0,
if(event = '$pageleave', 1, 0) as step_1,
if(step_1 = 1, timestamp, null) as latest_1,
array(replaceRegexpAll(JSONExtractRaw(properties, '$feature/a-b-test'), '^"|"$', '')) AS prop_basic,
prop_basic as prop,
argMinIf(prop, timestamp, notEmpty(arrayFilter(x -> notEmpty(x), prop))) over (PARTITION by aggregation_target) as prop_vals
FROM events e
LEFT OUTER JOIN
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
AND distinct_id IN
(SELECT distinct_id
FROM events
WHERE team_id = 2
AND event IN ['$pageleave', '$pageview']
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC') )
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0) AS pdi ON e.distinct_id = pdi.distinct_id
WHERE team_id = 2
AND event IN ['$pageleave', '$pageview']
AND toTimeZone(timestamp, 'UTC') >= toDateTime('2020-01-01 00:00:00', 'UTC')
AND toTimeZone(timestamp, 'UTC') <= toDateTime('2020-01-06 00:00:00', 'UTC')
AND (step_0 = 1
OR step_1 = 1) )))
WHERE step_0 = 1 ))
GROUP BY aggregation_target,
steps,
prop
HAVING steps = max(max_steps))
GROUP BY prop
'''
# ---
# name: ClickhouseTestFunnelExperimentResults.test_experiment_flow_with_event_results_with_hogql_aggregation
'''
/* user_id:0 celery:posthog.tasks.tasks.sync_insight_caching_state */
Expand Down
208 changes: 208 additions & 0 deletions posthog/api/test/__snapshots__/test_feature_flag.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -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)
'''
# ---
Loading

0 comments on commit e1669d9

Please sign in to comment.