From 34370ca63d2857fff029a1886ecb05b37c8083a5 Mon Sep 17 00:00:00 2001 From: James Greenhill Date: Thu, 14 Nov 2024 10:12:41 -0800 Subject: [PATCH] max(max_steps) --- posthog/hogql_queries/insights/funnels/base.py | 2 +- posthog/queries/funnels/funnel.py | 2 +- posthog/queries/funnels/funnel_strict.py | 4 ++-- posthog/queries/funnels/funnel_unordered.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/posthog/hogql_queries/insights/funnels/base.py b/posthog/hogql_queries/insights/funnels/base.py index bf5717ea74832..75815c634bb08 100644 --- a/posthog/hogql_queries/insights/funnels/base.py +++ b/posthog/hogql_queries/insights/funnels/base.py @@ -1167,7 +1167,7 @@ def _get_step_counts_query(self, outer_select: list[ast.Expr], inner_select: lis ) ), group_by=group_by_columns, - having=parse_expr("steps = max_steps"), + having=parse_expr("steps = max(max_steps)"), ) def actor_query( diff --git a/posthog/queries/funnels/funnel.py b/posthog/queries/funnels/funnel.py index 340d9e405eefb..e5b45c183377e 100644 --- a/posthog/queries/funnels/funnel.py +++ b/posthog/queries/funnels/funnel.py @@ -50,7 +50,7 @@ def get_step_counts_query(self): {steps_per_person_query} ) ) GROUP BY aggregation_target, steps {breakdown_clause} - HAVING steps = max_steps + HAVING steps = max(max_steps) """ def get_step_counts_without_aggregation_query(self): diff --git a/posthog/queries/funnels/funnel_strict.py b/posthog/queries/funnels/funnel_strict.py index e31bc87bc774c..f7115551814d7 100644 --- a/posthog/queries/funnels/funnel_strict.py +++ b/posthog/queries/funnels/funnel_strict.py @@ -26,8 +26,8 @@ def get_step_counts_query(self): SELECT aggregation_target, steps, max(steps) over (PARTITION BY aggregation_target {breakdown_clause}) as max_steps {self._get_step_time_names(max_steps)} {breakdown_clause} {inner_timestamps} {self._get_matching_events(max_steps)} {self._get_person_and_group_properties()} FROM ( {steps_per_person_query} ) - ) WHERE steps = max_steps - GROUP BY aggregation_target, steps {breakdown_clause} + ) GROUP BY aggregation_target, steps {breakdown_clause} + HAVING steps = max(max_steps) """ def get_step_counts_without_aggregation_query(self): diff --git a/posthog/queries/funnels/funnel_unordered.py b/posthog/queries/funnels/funnel_unordered.py index ee984b9462a75..a7ad5800a5da5 100644 --- a/posthog/queries/funnels/funnel_unordered.py +++ b/posthog/queries/funnels/funnel_unordered.py @@ -81,7 +81,7 @@ def get_step_counts_query(self): {union_query} ) ) GROUP BY aggregation_target, steps {breakdown_clause} - HAVING steps = max_steps + HAVING steps = max(max_steps) """ def get_step_counts_without_aggregation_query(self):