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.

fix(data-warehouse): stop reporting reverted views as failing to refresh (#95025)

Jovan Sakovic91ad61a64622
diff --git a/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py b/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py
index 7ebb9eda72a2..ef823944db47 100644
--- a/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py
+++ b/products/data_warehouse/backend/temporal/health_checks/materialized_view_failure.py
@@ -81,7 +81,7 @@ class MaterializedViewFailureCheck(HealthCheck):
DataWarehouseSavedQuery.objects
# `deleted` is nullable and NULL on views that were never deleted, which `deleted=False` drops.
.exclude(deleted=True)
- .filter(team_id__in=team_ids)
+ .filter(team_id__in=team_ids, is_materialized=True)
.annotate(
latest_job_status=Subquery(latest_job.values("status")[:1]),
latest_job_error=Subquery(latest_job.values("error")[:1]),
diff --git a/products/data_warehouse/backend/tests/test_materialized_view_failure_check.py b/products/data_warehouse/backend/tests/test_materialized_view_failure_check.py
index eb1b14cae706..11d15ca8c03e 100644
--- a/products/data_warehouse/backend/tests/test_materialized_view_failure_check.py
+++ b/products/data_warehouse/backend/tests/test_materialized_view_failure_check.py
@@ -25,13 +25,14 @@ class TestMaterializedViewFailureCheck(BaseTest):
status: str | None = None,
latest_error: str | None = None,
deleted: bool | None = False,
+ is_materialized: bool = True,
) -> DataWarehouseSavedQuery:
return DataWarehouseSavedQuery.objects.create(
team=self.team,
name=name,
query={"kind": "HogQLQuery", "query": "select 1"},
created_by=self.user,
- is_materialized=True,
+ is_materialized=is_materialized,
status=status,
latest_error=latest_error,
deleted=deleted,
@@ -102,6 +103,13 @@ class TestMaterializedViewFailureCheck(BaseTest):
self._job(view, DataModelingJobStatus.FAILED)
assert self._detected_ids() == set()
+ def test_a_view_that_is_no_longer_materialized_is_not_reported(self) -> None:
+ # Reverting a materialization leaves its last failed run as the newest job.
+ # Nothing is expected to refresh the view any more, so there is no stale data to warn about.
+ view = self._view(is_materialized=False)
+ self._job(view, DataModelingJobStatus.FAILED)
+ assert self._detected_ids() == set()
+
def test_the_reported_error_comes_from_the_failing_run(self) -> None:
view = self._view(latest_error="Unknown table 'old_name'")
self._job(view, DataModelingJobStatus.FAILED, error="Memory limit exceeded")