diff --git a/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr b/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr index 1b2aaac528cc9..24214a5f8dcea 100644 --- a/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr +++ b/posthog/hogql/transforms/test/__snapshots__/test_in_cohort.ambr @@ -3,12 +3,26 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, 1), 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)) + SELECT + events.event AS event + + 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, 1), 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)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1 @@ -41,12 +55,26 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, [2]))) 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)) + SELECT + events.event AS event + + 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, [2]))) 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)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1 @@ -79,12 +107,26 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, [3]))) 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)) + SELECT + events.event AS event + + 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, [3]))) 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)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1 @@ -117,14 +159,33 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, 4)) - GROUP BY cohortpeople.person_id, cohortpeople.cohort_id, cohortpeople.version - HAVING ifNull(greater(sum(cohortpeople.sign), 0), 0)) AS in_cohort__4 ON equals(in_cohort__4.person_id, events.person_id) - WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__4.matched, 1), 0), equals(events.event, %(hogql_val_0)s)) + SELECT + events.event AS event + + 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, 4)) + + GROUP BY + cohortpeople.person_id, + cohortpeople.cohort_id, + cohortpeople.version + + HAVING + ifNull(greater(sum(cohortpeople.sign), 0), 0)) AS in_cohort__4 ON equals(in_cohort__4.person_id, events.person_id) + + WHERE + and(equals(events.team_id, 420), ifNull(equals(in_cohort__4.matched, 1), 0), equals(events.event, %(hogql_val_0)s)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1 @@ -164,12 +225,25 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, 5))) AS in_cohort__5 ON equals(in_cohort__5.person_id, events.person_id) - WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__5.matched, 1), 0)) + SELECT + events.event AS event + + 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, 5))) AS in_cohort__5 ON equals(in_cohort__5.person_id, events.person_id) + + WHERE + and(equals(events.team_id, 420), ifNull(equals(in_cohort__5.matched, 1), 0)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1 @@ -201,12 +275,25 @@ ''' -- ClickHouse - SELECT events.event AS event - 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, 6))) AS in_cohort__6 ON equals(in_cohort__6.person_id, events.person_id) - WHERE and(equals(events.team_id, 420), ifNull(equals(in_cohort__6.matched, 1), 0)) + SELECT + events.event AS event + + 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, 6))) AS in_cohort__6 ON equals(in_cohort__6.person_id, events.person_id) + + WHERE + and(equals(events.team_id, 420), ifNull(equals(in_cohort__6.matched, 1), 0)) + LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1