: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(replay): exclude properties_group_* from recording export event query (#64993)
Paul D'Ambra56f091f64133
diff --git a/posthog/temporal/session_replay/export_recording/activities.py b/posthog/temporal/session_replay/export_recording/activities.pyindex 9c61a351eba2..d81a2a4aa5c1 100644--- a/posthog/temporal/session_replay/export_recording/activities.py+++ b/posthog/temporal/session_replay/export_recording/activities.py@@ -98,8 +98,13 @@ async def export_event_clickhouse_rows(input: ExportContext) -> None:logger = LOGGER.bind()logger.info(f"Exporting event ClickHouse rows for session {input.session_id}")+ # Exclude internal materialized columns: mat_/dmat_ materialized properties and the+ # properties_group_* map columns. The latter churn (added/dropped by migrations, e.g.+ # properties_group_ai_large), and a bare SELECT * breaks with "no column ... in table+ # 'sharded_events'" whenever the distributed and sharded schemas are briefly out of step.+ # They duplicate data already in `properties`, so an export never needs them.query: str = """- SELECT * EXCEPT('mat_.*|dmat_.*')+ SELECT * EXCEPT('mat_.*|dmat_.*|properties_group_.*')FROM eventsWHEREteam_id = %(team_id)s ANDdiff --git a/posthog/temporal/tests/session_replay/export_recording/test_activities.py b/posthog/temporal/tests/session_replay/export_recording/test_activities.pyindex 7bdabe04d435..9da7e10f4e9f 100644--- a/posthog/temporal/tests/session_replay/export_recording/test_activities.py+++ b/posthog/temporal/tests/session_replay/export_recording/test_activities.py@@ -162,6 +162,12 @@ async def test_export_event_clickhouse_rows_success():await export_event_clickhouse_rows(export_context)mock_client.aget_query.assert_called_once()+ # the events SELECT * must exclude the internal materialized columns, including the+ # churny properties_group_* maps, otherwise the query breaks whenever the distributed+ # and sharded schemas are briefly out of step (e.g. dropping properties_group_ai_large)+ executed_query = mock_client.aget_query.call_args.kwargs["query"]+ assert "properties_group_.*" in executed_query+mock_redis.setex.assert_called_once()call_args = mock_redis.setex.call_argsassert call_args[0][0] == _redis_key(export_id, "events")