: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(endpoints): honor filters_override compareFilter on materialized reads (#122945)
Jovan Sakovic339bd6d5cdb8
diff --git a/products/endpoints/backend/logic/materialized_serving.py b/products/endpoints/backend/logic/materialized_serving.pyindex a86ffe0e1b1b..488a67bc2674 100644--- a/products/endpoints/backend/logic/materialized_serving.py+++ b/products/endpoints/backend/logic/materialized_serving.py@@ -46,6 +46,10 @@ class MaterializedServingState:return Falseif data.refresh == EndpointRefreshMode.DIRECT:return False+ if data.filters_override is not None and data.filters_override.model_dump(+ exclude={"properties"}, exclude_none=True+ ):+ return Falseif data.variables:requested = set(data.variables.keys())if not self.servable_variables or not requested.issubset(self.servable_variables):diff --git a/products/endpoints/backend/tests/test_insight_response_parity.py b/products/endpoints/backend/tests/test_insight_response_parity.pyindex 6460ae9a2735..05e7e3113bc1 100644--- a/products/endpoints/backend/tests/test_insight_response_parity.py+++ b/products/endpoints/backend/tests/test_insight_response_parity.py@@ -171,6 +171,47 @@ class TestInsightResponseParity(ClickhouseTestMixin, APIBaseTest):assert len(first["labels"]) == 10, f"Expected 10 labels, got {len(first['labels'])}"assert len(first["days"]) == 10, f"Expected 10 days, got {len(first['days'])}"+ def test_materialized_trends_compare_override_matches_inline_response(self):+ endpoint = create_endpoint_with_version(+ name="trends_compare_override_parity",+ team=self.team,+ query=self._trends_query(+ series=[EventsNode(event="$pageview")],+ dateRange={"date_from": "2026-01-06", "date_to": "2026-01-10"},+ ),+ created_by=self.user,+ is_active=True,+ )+ filters_override = {"compareFilter": {"compare": True}}++ inline_response = self._run_endpoint(endpoint, filters_override=filters_override)+ assert inline_response.status_code == status.HTTP_200_OK, inline_response.json()+ inline_data = inline_response.json()++ saved_query = self._materialize_endpoint(endpoint)+ flat_response = process_query_model(+ self.team,+ HogQLQuery.model_validate(saved_query.query),+ user=self.user,+ )+ assert isinstance(flat_response, HogQLQueryResponse | CachedHogQLQueryResponse)++ def execute_query(team, query, *args, **kwargs):+ if isinstance(query, HogQLQuery):+ return flat_response+ return process_query_model(team, query, *args, **kwargs)++ with mock.patch(+ "products.endpoints.backend.logic.execution.process_query_model",+ side_effect=execute_query,+ ):+ materialized_response = self._run_endpoint(endpoint, filters_override=filters_override)++ assert materialized_response.status_code == status.HTTP_200_OK, materialized_response.json()+ materialized_data = materialized_response.json()+ assert len(materialized_data["results"]) == len(inline_data["results"]) == 2+ assert materialized_data["resolved_compare_date_range"] == inline_data["resolved_compare_date_range"]+def test_materialized_trends_with_breakdown_has_insight_shape(self):endpoint = create_endpoint_with_version(name="trends_bd_parity",