Skip to content

Commit

Permalink
lots more things should be being cleaned
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra committed Oct 30, 2024
1 parent a6914b8 commit bf99373
Show file tree
Hide file tree
Showing 3 changed files with 178 additions and 193 deletions.
4 changes: 3 additions & 1 deletion posthog/hogql/test/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

from pydantic import BaseModel

from posthog.test.base import clean_varying_query_parts


def pretty_print_in_tests(query: str, team_id: int) -> str:
query = (
Expand All @@ -27,7 +29,7 @@ def pretty_print_response_in_tests(response: Any, team_id: int) -> str:
clickhouse = response.clickhouse
hogql = response.hogql
query = "-- ClickHouse\n" + clickhouse + "\n\n-- HogQL\n" + hogql
return pretty_print_in_tests(query, team_id)
return clean_varying_query_parts(pretty_print_in_tests(query, team_id), False)


def pretty_dataclasses(obj, seen=None, indent=0):
Expand Down
28 changes: 14 additions & 14 deletions posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
FROM events LEFT JOIN (
SELECT cohortpeople.person_id AS cohort_person_id, 1 AS matched, cohortpeople.cohort_id AS cohort_id
FROM cohortpeople
WHERE and(equals(cohortpeople.team_id, 420), equals(cohortpeople.cohort_id, XX), equals(cohortpeople.version, 0))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 420), and(1, equals(events.event, %(hogql_val_0)s)), ifNull(equals(__in_cohort.matched, 1), 0))
WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, XX), equals(cohortpeople.version, 0))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 2), and(1, equals(events.event, %(hogql_val_0)s)), ifNull(equals(__in_cohort.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand All @@ -31,8 +31,8 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS cohort_person_id, 1 AS matched, person_static_cohort.cohort_id AS cohort_id
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [6]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0))
WHERE and(equals(person_static_cohort.team_id, 2), in(person_static_cohort.cohort_id, [1, 2, 3, 4, 5 /* ... */]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 2), 1, ifNull(equals(__in_cohort.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand All @@ -42,7 +42,7 @@
FROM events LEFT JOIN (
SELECT person_id AS cohort_person_id, 1 AS matched, cohort_id
FROM static_cohort_people
WHERE in(cohort_id, [6])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE in(cohort_id, [2])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE and(1, equals(__in_cohort.matched, 1))
LIMIT 100
'''
Expand All @@ -55,8 +55,8 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS cohort_person_id, 1 AS matched, person_static_cohort.cohort_id AS cohort_id
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), in(person_static_cohort.cohort_id, [7]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 420), 1, ifNull(equals(__in_cohort.matched, 1), 0))
WHERE and(equals(person_static_cohort.team_id, 2), in(person_static_cohort.cohort_id, [1, 2, 3, 4, 5 /* ... */]))) AS __in_cohort ON equals(__in_cohort.cohort_person_id, events.person_id)
WHERE and(equals(events.team_id, 2), 1, ifNull(equals(__in_cohort.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand All @@ -66,7 +66,7 @@
FROM events LEFT JOIN (
SELECT person_id AS cohort_person_id, 1 AS matched, cohort_id
FROM static_cohort_people
WHERE in(cohort_id, [7])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE in(cohort_id, [3])) AS __in_cohort ON equals(__in_cohort.cohort_person_id, person_id)
WHERE and(1, equals(__in_cohort.matched, 1))
LIMIT 100
'''
Expand All @@ -79,10 +79,10 @@
FROM events LEFT JOIN (
SELECT cohortpeople.person_id AS person_id, 1 AS matched
FROM cohortpeople
WHERE and(equals(cohortpeople.team_id, 420), equals(cohortpeople.cohort_id, XX))
WHERE and(equals(cohortpeople.team_id, 2), equals(cohortpeople.cohort_id, XX))
GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version
HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0)) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id)
WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0), equals(events.event, %(hogql_val_0)s))
WHERE and(equals(events.team_id, 2), ifNull(equals(in_cohort__XX.matched, 1), 0), equals(events.event, %(hogql_val_0)s))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand All @@ -107,8 +107,8 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS person_id, 1 AS matched
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id)
WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0))
WHERE and(equals(person_static_cohort.team_id, 2), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id)
WHERE and(equals(events.team_id, 2), ifNull(equals(in_cohort__XX.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand All @@ -131,8 +131,8 @@
FROM events LEFT JOIN (
SELECT person_static_cohort.person_id AS person_id, 1 AS matched
FROM person_static_cohort
WHERE and(equals(person_static_cohort.team_id, 420), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id)
WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__XX.matched, 1), 0))
WHERE and(equals(person_static_cohort.team_id, 2), equals(person_static_cohort.cohort_id, XX))) AS in_cohort__XX ON equals(in_cohort__XX.person_id, events.person_id)
WHERE and(equals(events.team_id, 2), ifNull(equals(in_cohort__XX.matched, 1), 0))
LIMIT 100
SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, format_csv_allow_double_quotes=0, max_ast_elements=4000000, max_expanded_ast_elements=4000000, max_bytes_before_external_group_by=0

Expand Down
Loading

0 comments on commit bf99373

Please sign in to comment.