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

fix: hogql tests should run through the query cleaning code to avoid flaps #25900

Merged
merged 19 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
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
12 changes: 6 additions & 6 deletions ee/api/test/__snapshots__/test_organization_resource_access.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"posthog_user"."events_column_config",
"posthog_user"."email_opt_in"
FROM "posthog_user"
WHERE "posthog_user"."id" = 2
WHERE "posthog_user"."id" = 99999
LIMIT 21
'''
# ---
Expand Down Expand Up @@ -62,7 +62,7 @@
SELECT 1 AS "a"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
AND "posthog_organizationmembership"."user_id" = 99999)
LIMIT 1
'''
# ---
Expand All @@ -76,7 +76,7 @@
"posthog_organizationmembership"."updated_at"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
AND "posthog_organizationmembership"."user_id" = 99999)
LIMIT 21
'''
# ---
Expand Down Expand Up @@ -146,7 +146,7 @@
SELECT 1 AS "a"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
AND "posthog_organizationmembership"."user_id" = 99999)
LIMIT 1
'''
# ---
Expand All @@ -160,7 +160,7 @@
"posthog_organizationmembership"."updated_at"
FROM "posthog_organizationmembership"
WHERE ("posthog_organizationmembership"."organization_id" = '00000000-0000-0000-0000-000000000000'::uuid
AND "posthog_organizationmembership"."user_id" = 2)
AND "posthog_organizationmembership"."user_id" = 99999)
LIMIT 21
'''
# ---
Expand Down Expand Up @@ -213,7 +213,7 @@
"posthog_user"."events_column_config",
"posthog_user"."email_opt_in"
FROM "posthog_user"
WHERE "posthog_user"."id" = 2
WHERE "posthog_user"."id" = 99999
LIMIT 21
'''
# ---
Expand Down
76 changes: 38 additions & 38 deletions ee/clickhouse/models/test/__snapshots__/test_cohort.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,18 @@
/* cohort_calculation: */
INSERT INTO cohortpeople
SELECT id,
2 as cohort_id,
2 as team_id,
99999 as cohort_id,
99999 as team_id,
1 AS sign,
0 AS version
FROM
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND id IN
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND ((((has(['something'], replaceRegexpAll(JSONExtractRaw(properties, '$some_prop'), '^"|"$', ''))))
AND ((has(['something'], replaceRegexpAll(JSONExtractRaw(properties, '$another_prop'), '^"|"$', '')))))) )
GROUP BY id
Expand All @@ -29,8 +29,8 @@
-1,
version
FROM cohortpeople
WHERE team_id = 2
AND cohort_id = 2
WHERE team_id = 99999
AND cohort_id = 99999
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
Expand All @@ -41,18 +41,18 @@
/* cohort_calculation: */
INSERT INTO cohortpeople
SELECT id,
2 as cohort_id,
2 as team_id,
99999 as cohort_id,
99999 as team_id,
1 AS sign,
0 AS version
FROM
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND id IN
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND ((has(['something1'], replaceRegexpAll(JSONExtractRaw(properties, '$some_prop'), '^"|"$', '')))) )
GROUP BY id
HAVING max(is_deleted) = 0
Expand All @@ -64,8 +64,8 @@
-1,
version
FROM cohortpeople
WHERE team_id = 2
AND cohort_id = 2
WHERE team_id = 99999
AND cohort_id = 99999
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
Expand All @@ -76,8 +76,8 @@
/* cohort_calculation: */
INSERT INTO cohortpeople
SELECT id,
2 as cohort_id,
2 as team_id,
99999 as cohort_id,
99999 as team_id,
1 AS sign,
0 AS version
FROM
Expand All @@ -93,10 +93,10 @@
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
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 = 2
WHERE team_id = 99999
AND event IN ['$pageview']
AND timestamp <= now()
AND timestamp >= now() - INTERVAL 2 year
Expand All @@ -107,11 +107,11 @@
FROM
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND id IN
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(properties, '$some_prop'), '^"|"$', ''))))))) )
GROUP BY id
HAVING max(is_deleted) = 0
Expand All @@ -126,8 +126,8 @@
-1,
version
FROM cohortpeople
WHERE team_id = 2
AND cohort_id = 2
WHERE team_id = 99999
AND cohort_id = 99999
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
Expand All @@ -138,14 +138,14 @@
SELECT uuid,
distinct_id
FROM events
WHERE team_id = 2
WHERE team_id = 99999
AND (distinct_id IN
(SELECT distinct_id
FROM
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
WHERE team_id = 99999
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0)
WHERE person_id IN
Expand All @@ -161,10 +161,10 @@
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
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 = 2
WHERE team_id = 99999
AND event IN ['$pageview']
AND timestamp <= now()
AND timestamp >= now() - INTERVAL 2 year
Expand All @@ -175,11 +175,11 @@
FROM
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND id IN
(SELECT id
FROM person
WHERE team_id = 2
WHERE team_id = 99999
AND (((((NOT has(['something1'], replaceRegexpAll(JSONExtractRaw(properties, '$some_prop'), '^"|"$', ''))))))) )
GROUP BY id
HAVING max(is_deleted) = 0
Expand All @@ -194,8 +194,8 @@
/* cohort_calculation: */
INSERT INTO cohortpeople
SELECT id,
2 as cohort_id,
2 as team_id,
99999 as cohort_id,
99999 as team_id,
1 AS sign,
0 AS version
FROM
Expand All @@ -209,10 +209,10 @@
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
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 = 2
WHERE team_id = 99999
AND event IN ['signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
Expand All @@ -225,8 +225,8 @@
-1,
version
FROM cohortpeople
WHERE team_id = 2
AND cohort_id = 2
WHERE team_id = 99999
AND cohort_id = 99999
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
Expand All @@ -237,8 +237,8 @@
/* cohort_calculation: */
INSERT INTO cohortpeople
SELECT id,
2 as cohort_id,
2 as team_id,
99999 as cohort_id,
99999 as team_id,
1 AS sign,
0 AS version
FROM
Expand All @@ -256,10 +256,10 @@
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
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 = 2
WHERE team_id = 99999
AND event IN ['$pageview', 'signup']
GROUP BY person_id) behavior_query
WHERE 1 = 1
Expand All @@ -273,8 +273,8 @@
-1,
version
FROM cohortpeople
WHERE team_id = 2
AND cohort_id = 2
WHERE team_id = 99999
AND cohort_id = 99999
AND version < 0
AND sign = 1 SETTINGS optimize_aggregation_in_order = 1,
join_algorithm = 'auto'
Expand Down
12 changes: 6 additions & 6 deletions ee/clickhouse/models/test/__snapshots__/test_property.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'''
SELECT uuid
FROM events
WHERE team_id = 2
WHERE team_id = 99999
AND ((has(['val_1'], replaceRegexpAll(JSONExtractRaw(properties, 'attr_1'), '^"|"$', ''))
AND has(['val_2'], replaceRegexpAll(JSONExtractRaw(properties, 'attr_2'), '^"|"$', '')))
OR (has(['val_2'], replaceRegexpAll(JSONExtractRaw(properties, 'attr_1'), '^"|"$', ''))))
Expand All @@ -13,14 +13,14 @@
'''
SELECT uuid
FROM events
WHERE team_id = 2
WHERE team_id = 99999
AND ((distinct_id IN
(SELECT distinct_id
FROM
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
WHERE team_id = 99999
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0)
WHERE person_id IN
Expand All @@ -30,7 +30,7 @@
argMax(properties, person._timestamp) as properties,
max(is_deleted) as is_deleted
FROM person
WHERE team_id = 2
WHERE team_id = 99999
GROUP BY id
HAVING is_deleted = 0)
WHERE has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(properties, 'email'), '^"|"$', '')) ) ))
Expand All @@ -40,7 +40,7 @@
(SELECT distinct_id,
argMax(person_id, version) as person_id
FROM person_distinct_id2
WHERE team_id = 2
WHERE team_id = 99999
GROUP BY distinct_id
HAVING argMax(is_deleted, version) = 0)
WHERE person_id IN
Expand All @@ -50,7 +50,7 @@
argMax(properties, person._timestamp) as properties,
max(is_deleted) as is_deleted
FROM person
WHERE team_id = 2
WHERE team_id = 99999
GROUP BY id
HAVING is_deleted = 0)
WHERE has(['[email protected]'], replaceRegexpAll(JSONExtractRaw(properties, 'email'), '^"|"$', '')) ) )))
Expand Down
Loading
Loading