Skip to content

: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.

feat(retention): consider only return event for property aggregation of different events (#57097)

Thomas Obermüller340744682f54
diff --git a/posthog/hogql_queries/insights/retention/retention_base_query_builder.py b/posthog/hogql_queries/insights/retention/retention_base_query_builder.py
index 2a0f46d14599..fb17600a7afc 100644
--- a/posthog/hogql_queries/insights/retention/retention_base_query_builder.py
+++ b/posthog/hogql_queries/insights/retention/retention_base_query_builder.py
@@ -83,6 +83,10 @@ class RetentionBaseQueryBuilder(ABC):
def is_custom_bracket_retention(self) -> bool:
return self.runner.is_custom_bracket_retention
+ @property
+ def has_property_aggregation(self) -> bool:
+ return self.runner.has_property_aggregation
+
@property
def minimum_occurrences(self) -> int:
return self.query.retentionFilter.minimumOccurrences or 1
diff --git a/posthog/hogql_queries/insights/retention/retention_base_query_fixed.py b/posthog/hogql_queries/insights/retention/retention_base_query_fixed.py
index 959de01e467f..f94f20215b9b 100644
--- a/posthog/hogql_queries/insights/retention/retention_base_query_fixed.py
+++ b/posthog/hogql_queries/insights/retention/retention_base_query_fixed.py
@@ -229,7 +229,7 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
return_entity_expr=self.return_entity_expr,
)
- if self.property_aggregation_expr:
+ if self.has_property_aggregation:
# For property aggregation, we need separate handling for start (interval 0) and return events (interval 1+).
# Tuples are (interval_start, value, actual_timestamp); actual_timestamp is used when start and
# return events differ to filter interval-0 return events that happen after the start event.
@@ -239,6 +239,7 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
# inlining the groupArrayIf expressions. This prevents ClickHouse from creating a self-join on the events
# table when these aggregations appear inside lambda functions (arrayFilter/arrayMap/arrayMin), which would
# otherwise cause MEMORY_LIMIT_EXCEEDED on large datasets.
+ assert self.property_aggregation_expr
start_event_data = parse_expr(
"""
groupArrayIf(
@@ -295,9 +296,7 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
# start event must have happened in the interval
is_valid_start_interval = self._is_valid_start_interval_expr()
retention_value_expr: ast.Expr | None
- intervals_from_base_expr, retention_value_expr = self._get_intervals_from_base_exprs(
- has_property_aggregation_aliases=bool(self.property_aggregation_expr and return_event_values)
- )
+ intervals_from_base_expr, retention_value_expr = self._get_intervals_from_base_exprs()
select_fields: list[ast.Expr] = [
ast.Alias(alias="actor_id", expr=ast.Field(chain=["events", self.aggregation_target_events_column])),
@@ -312,7 +311,8 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
# When using aggregation mode, add the grouped data arrays as named aliases BEFORE columns that reference them.
# This ensures ClickHouse uses the pre-aggregated arrays rather than re-executing the groupArrayIf inside
# lambda functions, which would otherwise trigger a self-join on the events table and exceed memory limits.
- if self.property_aggregation_expr and return_event_values:
+ if self.has_property_aggregation:
+ assert return_event_values is not None
start_event_data_raw, return_event_data_raw = return_event_values
select_fields.append(ast.Alias(alias="_start_event_data", expr=start_event_data_raw))
select_fields.append(ast.Alias(alias="_return_event_data", expr=return_event_data_raw))
@@ -481,21 +481,20 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
return parse_expr("has(start_event_timestamps, date_range[start_interval_index + 1])")
- def _get_intervals_from_base_exprs(
- self, has_property_aggregation_aliases: bool = False
- ) -> tuple[ast.Expr, ast.Expr | None]:
+ def _get_intervals_from_base_exprs(self) -> tuple[ast.Expr, ast.Expr | None]:
is_first_interval_after_start_event = self._is_first_interval_after_start_event_expr()
intervals_from_base_array_aggregator = "arrayJoin"
- if self.property_aggregation_expr and has_property_aggregation_aliases:
+ if self.has_property_aggregation:
# _start_event_data and _return_event_data are added as aliases before intervals_from_base is selected.
start_event_data_ref = ast.Field(chain=["_start_event_data"])
return_event_data_ref = ast.Field(chain=["_return_event_data"])
- # When start and return events are different event types, return events that occur
- # strictly after the start event within interval 0 are counted for that interval.
- # When they are the same event type, start_data already captures all occurrences in
- # interval 0; allowing return_data to also contribute would double-count.
+ # When start and return events are different, aggregation values should come from the
+ # return events only. Start events still add a zero-valued interval-0 marker so the
+ # cohort count stays consistent with normal retention.
+ # When they are the same event, start_data captures the interval-0 value and
+ # return_data contributes only later intervals to avoid double-counting.
different_event_entities = (
self.start_event.id != self.return_event.id or self.start_event.type != self.return_event.type
)
@@ -509,7 +508,7 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
arrayFilter(
x -> x.1 >= 0,
arrayMap(
- item -> (toInt(if(item.1 = date_range[start_interval_index + 1], 0, -1)), item.2),
+ item -> (toInt(if(item.1 = date_range[start_interval_index + 1], 0, -1)), 0.0),
{start_data}
)
),
@@ -631,7 +630,9 @@ class RetentionFixedIntervalBaseQueryBuilder(RetentionBaseQueryBuilder):
return_entity_expr: ast.Expr,
timestamp_field: ast.Expr | None = None,
) -> ast.Expr:
- if self.property_aggregation_expr:
+ if self.has_property_aggregation:
+ assert self.property_aggregation_expr
+
# Collect 3-tuples of (interval_start, value, actual_timestamp) for return events.
# actual_timestamp is needed to filter same-interval return events that happen after the start event.
return parse_expr(
diff --git a/posthog/hogql_queries/insights/retention/retention_query_runner.py b/posthog/hogql_queries/insights/retention/retention_query_runner.py
index 13bdd1a18af9..8e659ca6f5ec 100644
--- a/posthog/hogql_queries/insights/retention/retention_query_runner.py
+++ b/posthog/hogql_queries/insights/retention/retention_query_runner.py
@@ -636,7 +636,8 @@ class RetentionQueryRunner(AnalyticsQueryRunner[RetentionQueryResponse]):
interval_data = breakdown_data[start_interval]
interval_data[intervals_from_base] = interval_data.get(intervals_from_base, 0) + corrected_count
- if self.has_property_aggregation and aggregation_value is not None:
+ if self.has_property_aggregation:
+ assert isinstance(aggregation_value, int | float)
corrected_aggregation_value = correct_result_for_sampling(
aggregation_value, self.query.samplingFactor
)
diff --git a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr
index c61565cdcb07..837eaa5a4c4b 100644
--- a/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr
+++ b/posthog/hogql_queries/insights/retention/test/__snapshots__/test_retention_query_runner.ambr
@@ -480,6 +480,100 @@
use_hive_partitioning=0
'''
# ---
+# name: TestRetention.test_retention_aggregation_different_events_ignores_start_event_property_value
+ '''
+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,
+ actor_activity.intervals_from_base AS intervals_from_base,
+ count(DISTINCT actor_activity.actor_id) AS count,
+ sum(actor_activity.retention_value) AS aggregation_value
+ FROM
+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,
+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,
+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,
+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'signed_up'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,
+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, 'purchased'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,
+ arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,
+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date) -> if(has(start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range))) AS start_interval_index,
+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(ifNull(greater(x.1, date_range[plus(start_interval_index, 1)]), 0), and(ifNull(equals(x.1, date_range[plus(start_interval_index, 1)]), isNull(x.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), ifNull(greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> ifNull(equals(z.1, date_range[plus(start_interval_index, 1)]), isNull(z.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), _start_event_data)))), 0))), _return_event_data))))).1 AS intervals_from_base,
+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), 0.0), _start_event_data)), arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(minus(indexOf(arraySlice(date_range, plus(start_interval_index, 1), 8), item.1), 1), 'Int64'), item.2), arrayFilter(x -> or(ifNull(greater(x.1, date_range[plus(start_interval_index, 1)]), 0), and(ifNull(equals(x.1, date_range[plus(start_interval_index, 1)]), isNull(x.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), ifNull(greater(x.3, arrayMin(arrayMap(y -> y.3, arrayFilter(z -> ifNull(equals(z.1, date_range[plus(start_interval_index, 1)]), isNull(z.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), _start_event_data)))), 0))), _return_event_data))))).2 AS retention_value
+ FROM events
+ LEFT OUTER JOIN
+ (SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,
+ person_distinct_id_overrides.distinct_id AS distinct_id
+ FROM person_distinct_id_overrides
+ WHERE equals(person_distinct_id_overrides.team_id, 99999)
+ GROUP BY person_distinct_id_overrides.distinct_id
+ HAVING 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('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('purchased', 'signed_up')), or(equals(events.event, 'signed_up'), equals(events.event, 'purchased')))
+ GROUP BY actor_id
+ HAVING 1) AS actor_activity
+ GROUP BY start_event_matching_interval,
+ intervals_from_base
+ ORDER BY start_event_matching_interval ASC,
+ intervals_from_base ASC
+ LIMIT 100000 SETTINGS readonly=2,
+ max_execution_time=600,
+ allow_experimental_object_type=1,
+ max_ast_elements=4000000,
+ max_expanded_ast_elements=4000000,
+ max_bytes_before_external_group_by=23622320128,
+ transform_null_in=1,
+ optimize_min_equality_disjunction_chain_length=4294967295,
+ allow_experimental_join_condition=1,
+ use_hive_partitioning=0
+ '''
+# ---
+# name: TestRetention.test_retention_aggregation_sum
+ '''
+ SELECT actor_activity.start_interval_index AS start_event_matching_interval,
+ actor_activity.intervals_from_base AS intervals_from_base,
+ count(DISTINCT actor_activity.actor_id) AS count,
+ sum(actor_activity.retention_value) AS aggregation_value
+ FROM
+ (SELECT if(not(empty(events__override.distinct_id)), events__override.person_id, events.person_id) AS actor_id,
+ arraySort(groupUniqArrayIf(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC')))))) AS start_event_timestamps,
+ arrayMap(x -> plus(toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1)), toIntervalDay(x)), range(0, 7)) AS date_range,
+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _start_event_data,
+ groupArrayIf(tuple(toStartOfDay(toTimeZone(events.timestamp, 'UTC')), ifNull(accurateCastOrNull(replaceRegexpAll(nullIf(nullIf(JSONExtractRaw(events.properties, 'revenue'), ''), 'null'), '^"|"$', ''), 'Float64'), 0.0), toTimeZone(events.timestamp, 'UTC')), and(equals(events.event, '$pageview'), and(greaterOrEquals(toTimeZone(events.timestamp, 'UTC'), toStartOfInterval(assumeNotNull(toDateTime('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(toTimeZone(events.timestamp, 'UTC'), toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))))) AS _return_event_data,
+ arrayMap(x -> x.1, _return_event_data) AS return_event_timestamps,
+ arrayJoin(arrayFilter(x -> ifNull(greater(x, -1), 0), arrayMap((interval_index, interval_date) -> if(has(start_event_timestamps, interval_date), minus(interval_index, 1), -1), arrayEnumerate(date_range), date_range))) AS start_interval_index,
+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).1 AS intervals_from_base,
+ arrayJoin(arrayConcat(arrayFilter(x -> ifNull(greaterOrEquals(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(if(ifNull(equals(item.1, date_range[plus(start_interval_index, 1)]), isNull(item.1)
+ and isNull(date_range[plus(start_interval_index, 1)])), 0, -1), 'Int64'), item.2), _start_event_data)), arrayFilter(x -> ifNull(greater(x.1, 0), 0), arrayMap(item -> tuple(accurateCastOrNull(indexOf(arraySlice(date_range, plus(start_interval_index, 2), 7), item.1), 'Int64'), item.2), _return_event_data)))).2 AS retention_value
+ FROM events
+ LEFT OUTER JOIN
+ (SELECT tupleElement(argMax(tuple(person_distinct_id_overrides.person_id), person_distinct_id_overrides.version), 1) AS person_id,
+ person_distinct_id_overrides.distinct_id AS distinct_id
+ FROM person_distinct_id_overrides
+ WHERE equals(person_distinct_id_overrides.team_id, 99999)
+ GROUP BY person_distinct_id_overrides.distinct_id
+ HAVING 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('2020-06-10 00:00:00', 'UTC')), toIntervalDay(1))), less(events.timestamp, toDateTime64('explicit_redacted_timestamp', 6, 'UTC'))), in(events.event, tuple('$pageview')), or(equals(events.event, '$pageview'), equals(events.event, '$pageview')))
+ GROUP BY actor_id
+ HAVING 1) AS actor_activity
+ GROUP BY start_event_matching_interval,
+ intervals_from_base
+ ORDER BY start_event_matching_interval ASC,
+ intervals_from_base ASC
+ LIMIT 100000 SETTINGS readonly=2,
+ max_execution_time=600,
+ allow_experimental_object_type=1,
+ max_ast_elements=4000000,
+ max_expanded_ast_elements=4000000,
+ max_bytes_before_external_group_by=23622320128,
+ transform_null_in=1,
+ optimize_min_equality_disjunction_chain_length=4294967295,
+ allow_experimental_join_condition=1,
+ use_hive_partitioning=0
+ '''
+# ---
# name: TestRetention.test_retention_event_action
'''
SELECT actor_activity.start_interval_index AS start_event_matching_interval,
diff --git a/posthog/hogql_queries/insights/retention/test/test_retention_query_runner.py b/posthog/hogql_queries/insights/retention/test/test_retention_query_runner.py
index d0b57b4dec86..94fcc50511d8 100644
--- a/posthog/hogql_queries/insights/retention/test/test_retention_query_runner.py
+++ b/posthog/hogql_queries/insights/retention/test/test_retention_query_runner.py
@@ -4780,6 +4780,7 @@ class TestRetention(ClickhouseTestMixin, APIBaseTest):
# Verify the cohort filter was actually merged into query properties
assert runner.query.properties is not None
+ @snapshot_clickhouse_queries
def test_retention_aggregation_sum(self):
"""Test retention with SUM aggregation on a property"""
Person.objects.create(team=self.team, distinct_ids=["user1"])
@@ -5176,6 +5177,32 @@ class TestRetention(ClickhouseTestMixin, APIBaseTest):
# Interval 1: user1(100) only — user2 didn't return on day 1
self.assertEqual(day0_values[1]["aggregation_value"], 100)
+ @snapshot_clickhouse_queries
+ def test_retention_aggregation_different_events_ignores_start_event_property_value(self):
+ Person.objects.create(team=self.team, distinct_ids=["user1"])
+
+ _create_events(self.team, [("user1", _date(0, hour=10), {"revenue": 999})], event="signed_up")
+ _create_events(self.team, [("user1", _date(0, hour=12), {"revenue": 50})], event="purchased")
+
+ flush_persons_and_events()
+
+ result_sum = self.run_query(
+ query={
+ "dateRange": {"date_from": _date(0, hour=0), "date_to": _date(6)},
+ "retentionFilter": {
+ "totalIntervals": 7,
+ "targetEntity": {"id": "signed_up", "type": "events"},
+ "returningEntity": {"id": "purchased", "type": "events"},
+ "aggregationType": "sum",
+ "aggregationProperty": "revenue",
+ },
+ }
+ )
+
+ day0_values = result_sum[0]["values"]
+ self.assertEqual(day0_values[0]["count"], 1)
+ self.assertEqual(day0_values[0]["aggregation_value"], 50)
+
def test_retention_aggregation_different_events_interval_0_excludes_return_before_start(self):
# Return events that happen BEFORE the start event in the same interval must NOT be
# counted in interval 0, even when start and return events are different event types.
diff --git a/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr b/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
index 9fecf09af7c9..b8ad643c0e5a 100644
--- a/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
+++ b/posthog/hogql_queries/web_analytics/test/__snapshots__/test_web_stats_table.ambr
@@ -2086,6 +2086,8 @@
use_hive_partitioning=0
'''
# ---
+<<<<<<< HEAD
+=======
# name: TestWebStatsTableQueryRunner.test_entry_bounce_rate.2
'''
SELECT breakdown_value AS `context.columns.breakdown_value`,
@@ -2145,6 +2147,7 @@
use_hive_partitioning=0
'''
# ---
+>>>>>>> master
# name: TestWebStatsTableQueryRunner.test_entry_bounce_rate_one_user
'''
diff --git a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
index b56618bbf8da..c3c33d4047ff 100644
--- a/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
+++ b/posthog/session_recordings/test/__snapshots__/test_session_recording_playlist.ambr
@@ -1143,6 +1143,19 @@
'''
# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.32
+ '''
+ SELECT "posthog_teamrevenueanalyticsconfig"."team_id",
+ "posthog_teamrevenueanalyticsconfig"."filter_test_accounts",
+ "posthog_teamrevenueanalyticsconfig"."notified_first_sync",
+ "posthog_teamrevenueanalyticsconfig"."events",
+ "posthog_teamrevenueanalyticsconfig"."goals",
+ "posthog_teamrevenueanalyticsconfig"."base_currency"
+ FROM "posthog_teamrevenueanalyticsconfig"
+ WHERE "posthog_teamrevenueanalyticsconfig"."team_id" = 99999
+ LIMIT 21
+ '''
+# ---
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.33
'''
SELECT "posthog_externaldatasource"."created_by_id",
"posthog_externaldatasource"."created_at",
@@ -1176,7 +1189,7 @@
AND "posthog_externaldatasource"."deleted" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.33
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.34
'''
SELECT "posthog_datawarehousetable"."created_by_id",
"posthog_datawarehousetable"."created_at",
@@ -1232,7 +1245,7 @@
AND "posthog_externaldatasource"."access_method" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.34
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.35
'''
SELECT "posthog_datawarehousejoin"."created_by_id",
"posthog_datawarehousejoin"."created_at",
@@ -1252,7 +1265,7 @@
AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.35
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.36
'''
SELECT 1 AS "a"
FROM "access_control_propertyaccesscontrol"
@@ -1261,7 +1274,7 @@
LIMIT 1
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.36
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.37
'''
SELECT 1 AS "a"
FROM "access_control_propertyaccesscontrol"
@@ -1270,7 +1283,7 @@
LIMIT 1
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.37
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.38
'''
SELECT COUNT(*)
FROM
@@ -1279,7 +1292,7 @@
WHERE "ee_single_session_summary"."team_id" = 99999) subquery
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.38
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.39
'''
SELECT "posthog_user"."id",
"posthog_user"."password",
@@ -1322,7 +1335,7 @@
LIMIT 21
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.39
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.4
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
@@ -1360,7 +1373,7 @@
LIMIT 21
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.4
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.40
'''
SELECT "posthog_organization"."id",
"posthog_organization"."name",
@@ -1398,7 +1411,7 @@
LIMIT 21
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.40
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.41
'''
SELECT "posthog_team"."id",
"posthog_team"."uuid",
@@ -1527,7 +1540,7 @@
LIMIT 21
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.41
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.42
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
@@ -1574,7 +1587,7 @@
LIMIT 21
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.42
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.43
'''
SELECT "ee_accesscontrol"."id",
"ee_accesscontrol"."team_id",
@@ -1620,7 +1633,7 @@
AND "ee_accesscontrol"."team_id" = 99999))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.43
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.44
'''
SELECT "posthog_organizationmembership"."id",
"posthog_organizationmembership"."organization_id",
@@ -1665,7 +1678,7 @@
WHERE "posthog_organizationmembership"."user_id" = 99999
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.44
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.45
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_sessionrecordingplaylist"
@@ -1676,7 +1689,7 @@
AND NOT "posthog_sessionrecordingplaylist"."deleted")
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.45
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.46
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_sessionrecordingplaylist"
@@ -1687,7 +1700,7 @@
AND NOT "posthog_sessionrecordingplaylist"."deleted")
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.46
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.47
'''
SELECT "posthog_sessionrecordingplaylist"."id",
"posthog_sessionrecordingplaylist"."short_id",
@@ -1889,7 +1902,7 @@
LIMIT 100
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.47
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.48
'''
SELECT "posthog_sessionrecordingplaylistitem"."playlist_id" AS "playlist_id",
COUNT("posthog_sessionrecordingplaylistitem"."id") AS "c"
@@ -1906,7 +1919,7 @@
GROUP BY 1
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.48
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.49
'''
SELECT "posthog_sessionrecordingplaylistitem"."playlist_id" AS "playlist_id",
"posthog_sessionrecordingplaylistitem"."recording_id" AS "recording_id"
@@ -1920,15 +1933,6 @@
5 /* ... */))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.49
- '''
- SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"
- FROM "posthog_sessionrecordingviewed"
- WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999
- AND "posthog_sessionrecordingviewed"."user_id" = 99999
- AND "posthog_sessionrecordingviewed"."session_id" IN ('00000000-0000-0000-0000-000000000000'))
- '''
-# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.5
'''
SELECT "posthog_team"."id",
@@ -2059,6 +2063,15 @@
'''
# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.50
+ '''
+ SELECT "posthog_sessionrecordingviewed"."session_id" AS "session_id"
+ FROM "posthog_sessionrecordingviewed"
+ WHERE ("posthog_sessionrecordingviewed"."team_id" = 99999
+ AND "posthog_sessionrecordingviewed"."user_id" = 99999
+ AND "posthog_sessionrecordingviewed"."session_id" IN ('00000000-0000-0000-0000-000000000000'))
+ '''
+# ---
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.51
'''
SELECT COUNT(*) AS "__count"
FROM "posthog_sessionrecordingviewed"
@@ -2066,7 +2079,7 @@
AND "posthog_sessionrecordingviewed"."user_id" = 99999)
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.51
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.52
'''
SELECT COUNT(*)
FROM
@@ -2078,7 +2091,7 @@
AND NOT ("posthog_comment"."item_id" IS NULL))) subquery
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.52
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.53
'''
SELECT COUNT(*)
FROM
@@ -2089,7 +2102,7 @@
AND NOT ("posthog_sharingconfiguration"."recording_id" IS NULL))) subquery
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.53
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.54
'''
SELECT COUNT(*)
FROM
@@ -2104,7 +2117,7 @@
AND "posthog_exportedasset"."export_context" IS NOT NULL))) subquery
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.54
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.55
'''
SELECT "posthog_datawarehousesavedquery"."created_by_id",
"posthog_datawarehousesavedquery"."created_at",
@@ -2169,7 +2182,7 @@
ORDER BY "posthog_datawarehousesavedquery"."name" ASC
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.55
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.56
'''
SELECT "posthog_datawarehousesavedquery"."created_by_id",
"posthog_datawarehousesavedquery"."created_at",
@@ -2226,7 +2239,7 @@
AND "posthog_datawarehousesavedquery"."deleted" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.56
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.57
'''
SELECT "posthog_externaldatasource"."created_by_id",
"posthog_externaldatasource"."created_at",
@@ -2260,7 +2273,7 @@
AND "posthog_externaldatasource"."deleted" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.57
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.58
'''
SELECT "posthog_datawarehousetable"."created_by_id",
"posthog_datawarehousetable"."created_at",
@@ -2316,7 +2329,7 @@
AND "posthog_externaldatasource"."access_method" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.58
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.59
'''
SELECT "posthog_datawarehousejoin"."created_by_id",
"posthog_datawarehousejoin"."created_at",
@@ -2336,15 +2349,6 @@
AND "posthog_datawarehousejoin"."deleted" IS NOT NULL))
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.59
- '''
- SELECT 1 AS "a"
- FROM "access_control_propertyaccesscontrol"
- WHERE ("access_control_propertyaccesscontrol"."team_id" = 99999
- AND NOT ("access_control_propertyaccesscontrol"."property_definition_id" IS NULL))
- LIMIT 1
- '''
-# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.6
'''
SELECT "posthog_organizationmembership"."id",
@@ -2402,6 +2406,15 @@
'''
# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.61
+ '''
+ SELECT 1 AS "a"
+ FROM "access_control_propertyaccesscontrol"
+ WHERE ("access_control_propertyaccesscontrol"."team_id" = 99999
+ AND NOT ("access_control_propertyaccesscontrol"."property_definition_id" IS NULL))
+ LIMIT 1
+ '''
+# ---
+# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.62
'''
SELECT COUNT(*)
FROM
@@ -2410,13 +2423,6 @@
WHERE "ee_single_session_summary"."team_id" = 99999) subquery
'''
# ---
-# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.62
- '''
- SELECT "posthog_sessionrecordingplaylistitem"."session_id"
- FROM "posthog_sessionrecordingplaylistitem"
- WHERE "posthog_sessionrecordingplaylistitem"."playlist_id" = 99999
- '''
-# ---
# name: TestSessionRecordingPlaylist.test_filters_playlist_by_type.63
'''
SELECT COUNT(*) AS "__count"