:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
fix(clickhouse): fix transform_null_in wrapping (#60198)
Rory Shanksd194ae1271fa
diff --git a/posthog/hogql/printer/clickhouse.py b/posthog/hogql/printer/clickhouse.pyindex cc81112515fa..2ce1dd2fdad3 100644--- a/posthog/hogql/printer/clickhouse.py+++ b/posthog/hogql/printer/clickhouse.py@@ -1277,6 +1277,14 @@ class ClickHousePrinter(BasePrinter):elif node.op == ast.CompareOperationOp.In:return opelif node.op == ast.CompareOperationOp.NotIn:+ # With transform_null_in=1, ClickHouse rewrites notIn() to notNullIn().+ # In Distributed aggregate plans this can make the coordinator expect+ # a pre-rewrite aggregate column name while shards return the rewritten+ # one, e.g. minIf(..., notIn(...)) vs minIf(..., notNullIn(...)).+ # Wrapping nullable NOT IN matches the existing nullable materialized+ # column path and preserves transform_null_in=1 semantics.+ if nullable_left and not not_nullable and not in_join_constraint and not in_index_hint:+ return f"ifNull({op}, 1)"return opelif node.op == ast.CompareOperationOp.GlobalIn:passdiff --git a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr b/posthog/hogql/printer/test/__snapshots__/test_printer.ambrindex ddce04cf2c4c..c7bb68115ff2 100644--- a/posthog/hogql/printer/test/__snapshots__/test_printer.ambr+++ b/posthog/hogql/printer/test/__snapshots__/test_printer.ambr@@ -1137,7 +1137,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1173,7 +1173,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1209,7 +1209,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', 'null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', 'null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1245,7 +1245,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', '')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', '')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1281,7 +1281,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', 'other_value')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('[email protected]', 'other_value')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1317,7 +1317,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1353,7 +1353,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('NULL')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1389,7 +1389,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'test_prop'), ''), 'null'), '^"|"$', ''), tuple('null', 'NULL')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1749,7 +1749,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1785,7 +1785,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', 'null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', 'null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1821,7 +1821,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', '')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', '')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1893,7 +1893,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -1965,7 +1965,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -2325,7 +2325,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -2361,7 +2361,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', 'null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', 'null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -2397,7 +2397,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', '')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('[email protected]', '')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -2469,7 +2469,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,@@ -2541,7 +2541,7 @@'''SELECT events.distinct_id AS distinct_idFROM events- WHERE and(equals(events.team_id, 99999), notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')))+ WHERE and(equals(events.team_id, 99999), ifNull(notIn(nullIf(nullIf(events.mat_test_prop, ''), 'null'), tuple('null', 'NULL')), 1))ORDER BY events.distinct_id ASCLIMIT 100 SETTINGS readonly=2,max_execution_time=60,diff --git a/posthog/hogql/printer/test/test_printer.py b/posthog/hogql/printer/test/test_printer.pyindex d90a5e7b6848..3c8073fbec48 100644--- a/posthog/hogql/printer/test/test_printer.py+++ b/posthog/hogql/printer/test/test_printer.py@@ -2373,6 +2373,24 @@ class TestPrinter(BaseTest):f"FROM (SELECT min(toTimeZone(session_replay_events.min_first_timestamp, %(hogql_val_0)s)) AS start_time, sum(session_replay_events.click_count) AS click_count, sum(session_replay_events.keypress_count) AS keypress_count FROM session_replay_events WHERE equals(session_replay_events.team_id, {self.team.pk})) AS session_replay_events LIMIT {MAX_SELECT_RETURNED_ROWS}")+ def test_field_nullable_not_in(self):+ context = HogQLContext(team_id=self.team.pk, enable_select_queries=True, database=Database())+ context.database.get_table("events").fields["nullable_field"] = StringDatabaseField( # type: ignore+ name="nullable_field", nullable=True+ )++ generated_sql = self._select(+ "SELECT minIf(timestamp, nullable_field NOT IN ('a', 'b')) AS first_seen FROM events",+ context,+ )++ assert generated_sql == (+ "SELECT "+ "minIf(toTimeZone(events.timestamp, %(hogql_val_0)s), "+ "ifNull(notIn(events.nullable_field, tuple(%(hogql_val_1)s, %(hogql_val_2)s)), 1)) AS first_seen "+ f"FROM events WHERE equals(events.team_id, {self.team.pk}) LIMIT {MAX_SELECT_RETURNED_ROWS}"+ )+def test_assume_not_null_prevents_ifnull_wrapping_in_comparison(self):# base64Encode has no type signatures → returns UnknownType(nullable=True)# Without assumeNotNull, one side is considered nullable → comparison gets ifNull wrapping@@ -2477,6 +2495,17 @@ class TestPrinter(BaseTest):self.assertIn(f"in(events.`mat_$ai_trace_id`, tuple(%({trace1_param_key})s, %({trace2_param_key})s))", sql)self.assertNotIn("ifNull(in", sql)+ # NOT IN operations - no ifNull wrapping+ context = HogQLContext(team_id=self.team.pk, enable_select_queries=True)+ sql = self._select("SELECT * FROM events WHERE properties.$ai_trace_id NOT IN ('trace1', 'trace2')", context)++ trace1_param_key = next((k for k, v in context.values.items() if v == "trace1"), None)+ assert trace1_param_key is not None, "Expected 'trace1' to be recorded as a parameter value"+ trace2_param_key = next((k for k, v in context.values.items() if v == "trace2"), None)+ assert trace2_param_key is not None, "Expected 'trace2' to be recorded as a parameter value"+ self.assertIn(f"notIn(events.`mat_$ai_trace_id`, tuple(%({trace1_param_key})s, %({trace2_param_key})s))", sql)+ self.assertNotIn("ifNull(notIn", sql)+# Verify other properties still get normal treatmentmock_get_mat_col.return_value = None # No materialized column for other propscontext = HogQLContext(team_id=self.team.pk, enable_select_queries=True)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.ambrindex b9bf24f86982..3ca0288605e5 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@@ -209,7 +209,7 @@GROUP BY person.idHAVING and(ifNull(equals(argMax(person.is_deleted, person.version), 0), 0), ifNull(less(argMax(toTimeZone(person.created_at, 'UTC'), person.version), plus(now64(6, 'UTC'), toIntervalDay(1))), 0))))) SETTINGS optimize_aggregation_in_order=1) AS persons) AS persons ON equals(persons.id, funnel_actors.actor_id)) AS aggregation_target_with_propsGROUP BY (aggregation_target_with_props.prop).1, (aggregation_target_with_props.prop).2- HAVING notIn((aggregation_target_with_props.prop).1, [])+ HAVING ifNull(notIn((aggregation_target_with_props.prop).1, []), 1)LIMIT 100UNION ALL WITH funnel_actors AS(SELECT aggregation_target AS actor_id,@@ -2977,7 +2977,7 @@groups.group_key) AS groupsWHERE ifNull(equals(groups.index, 0), 0)) AS groups_0 ON equals(funnel_actors.actor_id, groups_0.key)) AS aggregation_target_with_propsGROUP BY (aggregation_target_with_props.prop).1, (aggregation_target_with_props.prop).2- HAVING notIn((aggregation_target_with_props.prop).1, [])+ HAVING ifNull(notIn((aggregation_target_with_props.prop).1, []), 1)LIMIT 100UNION ALL WITH funnel_actors AS(SELECT aggregation_target AS actor_id,@@ -3412,7 +3412,7 @@groups.group_key) AS groupsWHERE ifNull(equals(groups.index, 0), 0)) AS groups_0 ON equals(funnel_actors.actor_id, groups_0.key)) AS aggregation_target_with_propsGROUP BY (aggregation_target_with_props.prop).1, (aggregation_target_with_props.prop).2- HAVING notIn((aggregation_target_with_props.prop).1, [])+ HAVING ifNull(notIn((aggregation_target_with_props.prop).1, []), 1)LIMIT 100UNION ALL WITH funnel_actors AS(SELECT aggregation_target AS actor_id,@@ -4101,7 +4101,7 @@groups.group_key) AS groupsWHERE ifNull(equals(groups.index, 0), 0)) AS groups_0 ON equals(funnel_actors.actor_id, groups_0.key)) AS aggregation_target_with_propsGROUP BY (aggregation_target_with_props.prop).1, (aggregation_target_with_props.prop).2- HAVING notIn((aggregation_target_with_props.prop).1, [])+ HAVING ifNull(notIn((aggregation_target_with_props.prop).1, []), 1)LIMIT 100UNION ALL WITH funnel_actors AS(SELECT aggregation_target AS actor_id,@@ -4536,7 +4536,7 @@groups.group_key) AS groupsWHERE ifNull(equals(groups.index, 0), 0)) AS groups_0 ON equals(funnel_actors.actor_id, groups_0.key)) AS aggregation_target_with_propsGROUP BY (aggregation_target_with_props.prop).1, (aggregation_target_with_props.prop).2- HAVING notIn((aggregation_target_with_props.prop).1, [])+ HAVING ifNull(notIn((aggregation_target_with_props.prop).1, []), 1)LIMIT 100UNION ALL WITH funnel_actors AS(SELECT aggregation_target AS actor_id,diff --git a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambrindex d4e485f2104c..77872e954ea0 100644--- a/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr+++ b/products/product_analytics/backend/hogql_queries/paths/test/__snapshots__/test_paths_query_runner_ee.ambr@@ -231,7 +231,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(equals(events.event, '$pageview'), notIn(path_item, ['/bar/*/foo'])))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(equals(events.event, '$pageview'), ifNull(notIn(path_item, ['/bar/*/foo']), 1)))ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)GROUP BY person_id) ARRAYJOIN session_paths AS path_time_tuple,@@ -316,7 +316,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(equals(events.event, '$pageview'), notIn(path_item, ['/bar/*/foo'])))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(equals(events.event, '$pageview'), ifNull(notIn(path_item, ['/bar/*/foo']), 1)))ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)GROUP BY person_id) ARRAYJOIN session_paths AS path_time_tuple,@@ -656,7 +656,7 @@WHERE equals(person_distinct_id_overrides.team_id, 99999)GROUP BY person_distinct_id_overrides.distinct_idHAVING ifNull(equals(tupleElement(argMax(tuple(person_distinct_id_overrides.is_deleted), person_distinct_id_overrides.version), 1), 0), 0) SETTINGS optimize_aggregation_in_order=1) AS events__override ON equals(events.distinct_id, events__override.distinct_id)- WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen'), not(startsWith(events.event, '$'))), notIn(path_item, ['/custom1', '/1', '/2', '/3'])))+ WHERE and(equals(events.team_id, 99999), and(greaterOrEquals(events.timestamp, toStartOfInterval(assumeNotNull(toDateTime('2012-01-01 00:00:00', 'UTC')), toIntervalDay(1))), lessOrEquals(events.timestamp, assumeNotNull(toDateTime('2023-05-23 23:59:59', 'UTC')))), and(or(equals(events.event, '$pageview'), equals(events.event, '$screen'), not(startsWith(events.event, '$'))), ifNull(notIn(path_item, ['/custom1', '/1', '/2', '/3']), 1)))ORDER BY if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) ASC, toTimeZone(events.timestamp, 'UTC') ASC)GROUP BY person_id) ARRAYJOIN session_paths AS path_time_tuple,