diff --git a/posthog/clickhouse/client/execute.py b/posthog/clickhouse/client/execute.py index adcd9b726ac65..317fa66755e8a 100644 --- a/posthog/clickhouse/client/execute.py +++ b/posthog/clickhouse/client/execute.py @@ -41,8 +41,11 @@ @lru_cache(maxsize=1) def default_settings() -> dict: + # https://clickhouse.com/blog/clickhouse-fully-supports-joins-how-to-choose-the-right-algorithm-part5 + # We default to three memory bound join operations, in decreasing order of speed + # The merge algorithms are not memory bound, and can be selectively used in places where it makes sense return { - "join_algorithm": "direct,parallel_hash", + "join_algorithm": "direct,parallel_hash,hash", "distributed_replica_max_ignored_errors": 1000, } diff --git a/posthog/hogql/constants.py b/posthog/hogql/constants.py index a273f1da6919d..02e29cbfad351 100644 --- a/posthog/hogql/constants.py +++ b/posthog/hogql/constants.py @@ -105,3 +105,4 @@ class HogQLGlobalSettings(HogQLQuerySettings): max_expanded_ast_elements: Optional[int] = 2_000_000 max_query_size: Optional[int] = 262144 * 4 # default value 262144 (= 256 KiB) max_bytes_before_external_group_by: Optional[int] = 0 # default value means we don't swap ordering by to disk + allow_experimental_analyzer: Optional[bool] = None diff --git a/posthog/hogql_queries/insights/funnels/base.py b/posthog/hogql_queries/insights/funnels/base.py index 3389b4e4d26f1..c6bb8f5149e16 100644 --- a/posthog/hogql_queries/insights/funnels/base.py +++ b/posthog/hogql_queries/insights/funnels/base.py @@ -1022,9 +1022,7 @@ def _get_step_counts_query(self, outer_select: list[ast.Expr], inner_select: lis ) ), group_by=group_by_columns, - having=ast.CompareOperation( - left=ast.Field(chain=["steps"]), right=ast.Field(chain=["max_steps"]), op=ast.CompareOperationOp.Eq - ), + having=parse_expr("steps = max(max_steps)"), ) def actor_query( diff --git a/posthog/hogql_queries/insights/funnels/funnels_query_runner.py b/posthog/hogql_queries/insights/funnels/funnels_query_runner.py index 3ad62c08a1f66..a0e6404694502 100644 --- a/posthog/hogql_queries/insights/funnels/funnels_query_runner.py +++ b/posthog/hogql_queries/insights/funnels/funnels_query_runner.py @@ -97,8 +97,10 @@ def calculate(self): modifiers=self.modifiers, limit_context=self.limit_context, settings=HogQLGlobalSettings( - max_bytes_before_external_group_by=MAX_BYTES_BEFORE_EXTERNAL_GROUP_BY - ), # Make sure funnel queries never OOM + # Make sure funnel queries never OOM + max_bytes_before_external_group_by=MAX_BYTES_BEFORE_EXTERNAL_GROUP_BY, + allow_experimental_analyzer=True, + ), ) results = self.funnel_class._format_results(response.results) diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr index d53092966d4d1..fc56c51aa897d 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel.ambr @@ -84,8 +84,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -93,7 +93,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFOSSFunnel.test_funnel_conversion_window_seconds.1 @@ -180,8 +181,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -219,8 +220,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-05-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -331,8 +332,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -340,7 +341,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFOSSFunnel.test_funnel_with_precalculated_cohort_step_filter @@ -418,8 +420,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -427,7 +429,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFOSSFunnel.test_funnel_with_property_groups @@ -527,8 +530,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -536,7 +539,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFOSSFunnel.test_funnel_with_property_groups.1 @@ -635,8 +639,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -683,8 +687,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -797,8 +801,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -845,8 +849,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -959,8 +963,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -1007,8 +1011,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-07-01 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'user signed up')), or(and(ifNull(ilike(e__pdi__person.properties___email, '%.com%'), 0), ifNull(equals(e__pdi__person.properties___age, '20'), 0)), or(ifNull(ilike(e__pdi__person.properties___email, '%.org%'), 0), ifNull(equals(e__pdi__person.properties___age, '28'), 0)))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -1089,8 +1093,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -1098,7 +1102,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFOSSFunnel.test_timezones @@ -1153,8 +1158,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) LIMIT 100 SETTINGS readonly=2, max_execution_time=60, allow_experimental_object_type=1, @@ -1162,7 +1167,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen @@ -1248,8 +1254,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1259,7 +1265,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen_for_step @@ -1352,8 +1359,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1363,7 +1370,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelBreakdown.test_funnel_step_multiple_breakdown_snapshot @@ -1449,8 +1457,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1460,7 +1468,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events @@ -1587,8 +1596,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1598,7 +1607,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events_poe_v2 @@ -1725,8 +1735,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1736,7 +1746,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelGroupBreakdown.test_funnel_breakdown_group @@ -1870,8 +1881,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1881,7 +1892,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelGroupBreakdown.test_funnel_breakdown_group.1 diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr index ec72759642633..968e9f59ec233 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_breakdowns_by_current_url.ambr @@ -82,8 +82,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -93,7 +93,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelBreakdownsByCurrentURL.test_breakdown_by_pathname @@ -179,8 +180,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -190,6 +191,7 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr index ea5b333eec6d8..404380346de1c 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlation.ambr @@ -70,8 +70,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(event__pdi.person_id, funnel_actors.actor_id) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), notIn(event.event, [])) @@ -139,8 +139,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -220,8 +220,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors JOIN @@ -302,8 +302,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -425,8 +425,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -474,8 +474,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Positive'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -619,8 +619,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -668,8 +668,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Positive'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -813,8 +813,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -862,8 +862,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Negative'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -1007,8 +1007,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1056,8 +1056,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Negative'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1159,8 +1159,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors JOIN @@ -1241,8 +1241,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -1364,8 +1364,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -1413,8 +1413,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Positive'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -1558,8 +1558,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1607,8 +1607,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Positive'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1752,8 +1752,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -1801,8 +1801,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Negative'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -1946,8 +1946,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1995,8 +1995,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2020-01-14 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('paid', 'user signed up')), ifNull(equals(e__pdi__person.`properties___$browser`, 'Negative'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -2093,8 +2093,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_1`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), in(event.event, ['positively_related', 'negatively_related']))) @@ -2156,8 +2156,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -2232,8 +2232,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_1`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), in(event.event, ['positively_related', 'negatively_related']))) @@ -2295,8 +2295,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -2366,8 +2366,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), notIn(event.event, [])) @@ -2428,8 +2428,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -2532,8 +2532,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'positively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -2648,8 +2648,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'positively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -2764,8 +2764,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -2880,8 +2880,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -2971,8 +2971,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), notIn(event.event, [])) @@ -3041,8 +3041,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -3145,8 +3145,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -3261,8 +3261,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -3344,8 +3344,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), notIn(event.event, [])) @@ -3406,8 +3406,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -3510,8 +3510,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'positively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -3626,8 +3626,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'positively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -3742,8 +3742,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -3858,8 +3858,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -3949,8 +3949,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), notIn(event.event, [])) @@ -4019,8 +4019,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -4123,8 +4123,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -4239,8 +4239,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(funnel_actors.actor_id, event.`$group_0`) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2020-01-14 23:59:59', 6, 'UTC')))), notIn(event.event, ['paid', 'user signed up']), equals(event.event, 'negatively_related'), ifNull(notEquals(funnel_actors.steps, 2), 1)) @@ -4325,8 +4325,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -4399,8 +4399,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -4510,8 +4510,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -4633,8 +4633,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -4756,8 +4756,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -4879,8 +4879,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -4965,8 +4965,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -5039,8 +5039,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -5113,8 +5113,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -5187,8 +5187,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -5298,8 +5298,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -5421,8 +5421,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -5544,8 +5544,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -5667,8 +5667,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -5753,8 +5753,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -5827,8 +5827,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -5901,8 +5901,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -5975,8 +5975,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -6086,8 +6086,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -6209,8 +6209,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -6332,8 +6332,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -6455,8 +6455,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -6541,8 +6541,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -6615,8 +6615,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -6689,8 +6689,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -6763,8 +6763,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -6874,8 +6874,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -6997,8 +6997,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -7120,8 +7120,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -7243,8 +7243,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -7329,8 +7329,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -7403,8 +7403,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -7477,8 +7477,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -7551,8 +7551,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, @@ -7662,8 +7662,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -7785,8 +7785,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -7908,8 +7908,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -8031,8 +8031,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -8117,8 +8117,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LEFT JOIN @@ -8191,8 +8191,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors LIMIT 100 SETTINGS readonly=2, diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr index 2e49e8d40d3c9..e939cd2b30bfa 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_correlations_persons.ambr @@ -105,8 +105,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(event__pdi.person_id, funnel_actors.actor_id) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC')))), notIn(event.event, ['$pageview', 'insight analyzed']), equals(event.event, 'insight loaded'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -152,8 +152,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'insight analyzed'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(event__pdi.person_id, funnel_actors.actor_id) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC')))), notIn(event.event, ['$pageview', 'insight analyzed']), equals(event.event, 'insight loaded'), ifNull(equals(funnel_actors.steps, 2), 0)) @@ -360,8 +360,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(event__pdi.person_id, funnel_actors.actor_id) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC')))), notIn(event.event, ['$pageview', 'insight analyzed', 'insight updated']), equals(event.event, 'insight loaded'), ifNull(notEquals(funnel_actors.steps, 3), 1)) @@ -419,8 +419,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'insight analyzed', 'insight updated'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS funnel_actors ON equals(event__pdi.person_id, funnel_actors.actor_id) WHERE and(equals(event.team_id, 2), greaterOrEquals(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-01 00:00:00', 6, 'UTC'))), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC'))), equals(event.team_id, 2), greater(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), funnel_actors.first_timestamp), less(toTimeZone(toDateTime(toTimeZone(event.timestamp, 'UTC'), 'UTC'), 'UTC'), coalesce(funnel_actors.final_timestamp, plus(toTimeZone(funnel_actors.first_timestamp, 'UTC'), toIntervalDay(14)), assumeNotNull(parseDateTime64BestEffortOrNull('2021-01-08 23:59:59', 6, 'UTC')))), notIn(event.event, ['$pageview', 'insight analyzed', 'insight updated']), equals(event.event, 'insight loaded'), ifNull(notEquals(funnel_actors.steps, 3), 1)) @@ -564,8 +564,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -613,8 +613,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('$pageview', 'insight analyzed')), ifNull(equals(e__pdi__person.properties___foo, 'bar'), 0)), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -758,8 +758,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -807,8 +807,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), ifNull(equals(e__pdi__person.properties___foo, 'bar'), 0)))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(equals(funnel_actors.steps, 2), 0) @@ -952,8 +952,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) @@ -1001,8 +1001,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), ifNull(equals(e__pdi__person.properties___foo, 'bar'), 0)))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2]), 0) ORDER BY aggregation_target ASC) AS funnel_actors WHERE ifNull(notEquals(funnel_actors.steps, 2), 1) diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr index 02c3ed119fcad..2b88c6c1fdd97 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_persons.ambr @@ -150,8 +150,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -197,8 +197,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -381,8 +381,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -428,8 +428,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -612,8 +612,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(equals(steps, 2), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -659,8 +659,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(equals(steps, 2), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr index 4b80811bceb9f..453e2164d2150 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict.ambr @@ -81,8 +81,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -92,7 +92,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelStrictStepsBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen_for_step @@ -184,8 +185,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -195,7 +196,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelStrictStepsBreakdown.test_funnel_step_multiple_breakdown_snapshot @@ -280,8 +282,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -291,7 +293,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestStrictFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events @@ -395,8 +398,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -406,7 +409,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestStrictFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events_poe_v2 @@ -510,8 +514,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -521,7 +525,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group @@ -632,8 +637,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -643,7 +648,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestStrictFunnelGroupBreakdown.test_funnel_breakdown_group.1 diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr index e16a91afc1da2..910e0b5d6c51c 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_strict_persons.ambr @@ -110,8 +110,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -149,8 +149,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -293,8 +293,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -332,8 +332,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id @@ -476,8 +476,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(equals(steps, 2), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -515,8 +515,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(equals(steps, 2), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr index 64e95bb36e38f..22a3489348248 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_time_to_convert.ambr @@ -89,8 +89,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params) AS average_conversion_time FROM (SELECT plus( @@ -124,8 +124,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(floor(divide(minus(step_runs.step_1_average_conversion_time_inner, (SELECT histogram_params.from_seconds AS from_seconds FROM @@ -157,8 +157,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params)), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -190,8 +190,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -223,8 +223,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds, count() AS person_count FROM @@ -303,8 +303,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs GROUP BY bin_from_seconds) AS results RIGHT OUTER JOIN (SELECT plus( @@ -338,8 +338,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(numbers.number, (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -371,8 +371,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds FROM numbers(plus(ifNull( (SELECT histogram_params.bin_count AS bin_count @@ -405,8 +405,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), 0), 1)) AS numbers) AS fill ON equals(results.bin_from_seconds, fill.bin_from_seconds) ORDER BY fill.bin_from_seconds ASC LIMIT 100 SETTINGS readonly=2, @@ -416,7 +416,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelTimeToConvert.test_basic_strict @@ -490,8 +491,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params) AS average_conversion_time FROM (SELECT plus( @@ -520,8 +521,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(floor(divide(minus(step_runs.step_1_average_conversion_time_inner, (SELECT histogram_params.from_seconds AS from_seconds FROM @@ -548,8 +549,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params)), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -576,8 +577,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -604,8 +605,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds, count() AS person_count FROM @@ -665,8 +666,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs GROUP BY bin_from_seconds) AS results RIGHT OUTER JOIN (SELECT plus( @@ -695,8 +696,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(numbers.number, (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -723,8 +724,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds FROM numbers(plus(ifNull( (SELECT histogram_params.bin_count AS bin_count @@ -752,8 +753,8 @@ WHERE and(equals(e.team_id, 2), and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC')))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), 0), 1)) AS numbers) AS fill ON equals(results.bin_from_seconds, fill.bin_from_seconds) ORDER BY fill.bin_from_seconds ASC LIMIT 100 SETTINGS readonly=2, @@ -763,7 +764,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelTimeToConvert.test_basic_unordered @@ -925,8 +927,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params) AS average_conversion_time FROM (SELECT plus( @@ -987,8 +989,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(floor(divide(minus(step_runs.step_1_average_conversion_time_inner, (SELECT histogram_params.from_seconds AS from_seconds FROM @@ -1047,8 +1049,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params)), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -1107,8 +1109,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))), (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -1167,8 +1169,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds, count() AS person_count FROM @@ -1316,8 +1318,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs GROUP BY bin_from_seconds) AS results RIGHT OUTER JOIN (SELECT plus( @@ -1378,8 +1380,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), multiply(numbers.number, (SELECT histogram_params.bin_width_seconds AS bin_width_seconds FROM @@ -1438,8 +1440,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params))) AS bin_from_seconds FROM numbers(plus(ifNull( (SELECT histogram_params.bin_count AS bin_count @@ -1499,8 +1501,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-07 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-06-13 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) AS step_runs + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) AS step_runs WHERE isNotNull(step_runs.step_1_average_conversion_time_inner)) AS histogram_params), 0), 1)) AS numbers) AS fill ON equals(results.bin_from_seconds, fill.bin_from_seconds) ORDER BY fill.bin_from_seconds ASC LIMIT 100 SETTINGS readonly=2, @@ -1510,6 +1512,7 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr index 0d031da2b03a6..e02eb64d9a216 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_trends.ambr @@ -88,7 +88,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelTrends.test_timezones_trends.1 @@ -180,7 +181,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelTrends.test_week_interval @@ -272,7 +274,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelTrends.test_week_interval.1 diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr index f5cf1a29bdffa..778829c29b4da 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered.ambr @@ -135,8 +135,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -146,7 +146,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelUnorderedStepsBreakdown.test_funnel_breakdown_correct_breakdown_props_are_chosen_for_step @@ -299,8 +300,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -310,7 +311,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestFunnelUnorderedStepsBreakdown.test_funnel_step_multiple_breakdown_snapshot @@ -449,8 +451,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -460,7 +462,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestUnorderedFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events @@ -694,8 +697,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -705,7 +708,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestUnorderedFunnelGroupBreakdown.test_funnel_aggregate_by_groups_breakdown_group_person_on_events_poe_v2 @@ -939,8 +943,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -950,7 +954,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestUnorderedFunnelGroupBreakdown.test_funnel_breakdown_group @@ -1205,8 +1210,8 @@ GROUP BY aggregation_target, steps, prop - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) GROUP BY prop) GROUP BY final_prop LIMIT 100 SETTINGS readonly=2, @@ -1216,7 +1221,8 @@ max_ast_elements=2000000, max_expanded_ast_elements=2000000, max_query_size=1048576, - max_bytes_before_external_group_by=23622320128 + max_bytes_before_external_group_by=23622320128, + allow_experimental_analyzer=1 ''' # --- # name: TestUnorderedFunnelGroupBreakdown.test_funnel_breakdown_group.1 diff --git a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr index a0e57d8fac881..fc3fdd46e08fb 100644 --- a/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr +++ b/posthog/hogql_queries/insights/funnels/test/__snapshots__/test_funnel_unordered_persons.ambr @@ -254,8 +254,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -337,8 +337,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-01 00:00:00.000000', 6, 'UTC')), lessOrEquals(toTimeZone(e.timestamp, 'UTC'), toDateTime64('2021-01-08 23:59:59.999999', 6, 'UTC'))), in(e.event, tuple('step one', 'step three', 'step two'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0), ifNull(equals(step_2, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [1, 2, 3]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel.py b/posthog/hogql_queries/insights/funnels/test/test_funnel.py index 6b9d9e74a7bbf..2085579b5ba0c 100644 --- a/posthog/hogql_queries/insights/funnels/test/test_funnel.py +++ b/posthog/hogql_queries/insights/funnels/test/test_funnel.py @@ -3816,7 +3816,7 @@ def test_smoke(self): aggregation_target, steps HAVING - equals(steps, max_steps) + equals(steps, max(max_steps)) LIMIT 100""", ) @@ -3887,6 +3887,6 @@ def test_smoke(self): aggregation_target, steps HAVING - equals(steps, max_steps)) + equals(steps, max(max_steps))) LIMIT 100""", ) diff --git a/posthog/hogql_queries/insights/funnels/test/test_funnel_trends.py b/posthog/hogql_queries/insights/funnels/test/test_funnel_trends.py index 0fb294c6a64a4..7b86e305ca89e 100644 --- a/posthog/hogql_queries/insights/funnels/test/test_funnel_trends.py +++ b/posthog/hogql_queries/insights/funnels/test/test_funnel_trends.py @@ -1192,15 +1192,17 @@ def test_funnel_step_breakdown_empty(self): {"id": "step three", "order": 2}, ], "breakdown_type": "hogql", - "breakdown": "IF(rowNumberInAllBlocks() % 2 = 0, NULL, 'foo')", # Simulate some empty breakdown values + "breakdown": "IF(distinct_id = 'user_two', NULL, 'foo')", # Simulate some empty breakdown values } query = cast(FunnelsQuery, filter_to_query(filters)) results = FunnelsQueryRunner(query=query, team=self.team).calculate().results self.assertEqual(len(results), 2) - self.assertEqual(results[0]["breakdown_value"], ["None"]) + self.assertEqual(results[0]["breakdown_value"], [""]) + self.assertEqual(results[0]["data"], [0.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) self.assertEqual(results[1]["breakdown_value"], ["foo"]) + self.assertEqual(results[1]["data"], [100.0, 0.0, 100.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]) def test_funnel_step_breakdown_event_with_breakdown_limit(self): journeys_for( diff --git a/posthog/hogql_queries/insights/insight_actors_query_runner.py b/posthog/hogql_queries/insights/insight_actors_query_runner.py index 8b3e27df514a5..c07c1e3687ab0 100644 --- a/posthog/hogql_queries/insights/insight_actors_query_runner.py +++ b/posthog/hogql_queries/insights/insight_actors_query_runner.py @@ -1,6 +1,7 @@ from typing import cast, Optional from posthog.hogql import ast +from posthog.hogql.constants import HogQLGlobalSettings from posthog.hogql.query import execute_hogql_query from posthog.hogql_queries.insights.funnels.funnel_correlation_query_runner import FunnelCorrelationQueryRunner from posthog.hogql_queries.insights.funnels.funnels_query_runner import FunnelsQueryRunner @@ -107,6 +108,13 @@ def group_type_index(self) -> int | None: return None def calculate(self) -> HogQLQueryResponse: + settings = None + + # Funnel queries require the experimental analyzer to run correctly + # Can remove once clickhouse moves to version 24.3 or above + if isinstance(self.source_runner, FunnelsQueryRunner): + settings = HogQLGlobalSettings(allow_experimental_analyzer=True) + return execute_hogql_query( query_type="InsightActorsQuery", query=self.to_query(), @@ -114,4 +122,5 @@ def calculate(self) -> HogQLQueryResponse: timings=self.timings, modifiers=self.modifiers, limit_context=self.limit_context, + settings=settings, ) diff --git a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr index 0600e7e58e3b9..43bd72ebe2b82 100644 --- a/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr +++ b/posthog/hogql_queries/insights/test/__snapshots__/test_insight_actors_query_runner.ambr @@ -52,8 +52,8 @@ WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2]), 0) ORDER BY aggregation_target ASC) AS source INNER JOIN @@ -88,8 +88,8 @@ WHERE and(equals(e.team_id, 2), and(and(greaterOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), toDateTime64('2020-01-01 00:00:00.000000', 6, 'US/Pacific')), lessOrEquals(toTimeZone(e.timestamp, 'US/Pacific'), toDateTime64('2020-01-19 23:59:59.999999', 6, 'US/Pacific'))), in(e.event, tuple('$pageview'))), or(ifNull(equals(step_0, 1), 0), ifNull(equals(step_1, 1), 0))))) WHERE ifNull(equals(step_0, 1), 0))) GROUP BY aggregation_target, steps - HAVING ifNull(equals(steps, max_steps), isNull(steps) - and isNull(max_steps))) + HAVING ifNull(equals(steps, max(max_steps)), isNull(steps) + and isNull(max(max_steps)))) WHERE ifNull(in(steps, [2]), 0) ORDER BY aggregation_target ASC) AS source))) GROUP BY person.id