: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(data-modeling): include endpoint nodes in v2 DAG executable set (#67534)
Jovan Sakovic0ced0c28fde8
diff --git a/posthog/temporal/data_modeling/activities/get_dag_structure.py b/posthog/temporal/data_modeling/activities/get_dag_structure.pyindex 6d63ddb96f9a..19a939de0591 100644--- a/posthog/temporal/data_modeling/activities/get_dag_structure.py+++ b/posthog/temporal/data_modeling/activities/get_dag_structure.py@@ -41,7 +41,7 @@ class DAG:def _get_dag_structure_async(team_id: int, dag_id: str) -> DAG:"""Retrieve all nodes and edges for a DAG from the database."""nodes = Node.objects.filter(team_id=team_id, dag_id=dag_id)- executable_nodes = nodes.filter(type__in=[NodeType.VIEW, NodeType.MAT_VIEW])+ executable_nodes = nodes.filter(type__in=[NodeType.VIEW, NodeType.MAT_VIEW, NodeType.ENDPOINT])ephemeral_nodes = executable_nodes.filter(type=NodeType.VIEW)edges = (Edge.objects.prefetch_related("source", "target")diff --git a/posthog/temporal/tests/data_modeling/test_execute_dag_workflow.py b/posthog/temporal/tests/data_modeling/test_execute_dag_workflow.pyindex dddcf00f44b0..f385d6bbf813 100644--- a/posthog/temporal/tests/data_modeling/test_execute_dag_workflow.py+++ b/posthog/temporal/tests/data_modeling/test_execute_dag_workflow.py@@ -146,6 +146,30 @@ class TestGetDagStructureActivity:assert len(dag.executable_nodes) == 0assert len(dag.edges) == 0+ async def test_endpoint_nodes_are_executable(self, activity_environment, ateam, auser):+ # endpoints on a v2 DAG schedule must materialize; dropping ENDPOINT from the+ # executable filter silently stops their refresh (v1 frequency is cleared on migrate)+ dag = await database_sync_to_async(DAG.objects.create)(team=ateam, name="test-endpoint-dag")+ endpoint_query = await database_sync_to_async(DataWarehouseSavedQuery.objects.create)(+ team=ateam,+ name="endpoint_executable_test",+ query={"query": "SELECT 1", "kind": "HogQLQuery"},+ created_by=auser,+ )+ endpoint_node = await database_sync_to_async(Node.objects.create)(+ team=ateam,+ dag=dag,+ type=NodeType.ENDPOINT,+ saved_query=endpoint_query,+ )+ inputs = GetDAGStructureInputs(team_id=ateam.pk, dag_id=str(dag.id))+ result = await activity_environment.run(get_dag_structure_activity, inputs)+ assert str(endpoint_node.id) in result.executable_nodes+ assert str(endpoint_node.id) not in result.ephemeral_nodes+ await database_sync_to_async(endpoint_node.delete)()+ await database_sync_to_async(dag.delete)()+ await database_sync_to_async(endpoint_query.delete)()+async def test_identifies_ephemeral_nodes(self, activity_environment, ateam, auser):"""Test that ephemeral (VIEW) nodes are correctly identified."""dag = await database_sync_to_async(DAG.objects.create)(team=ateam, name="test-ephemeral-dag")