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-modeling): recompile endpoint saved query SQL in v1 workflow (#60061)

Jovan Sakovic9d09c126f43d
diff --git a/posthog/temporal/data_modeling/run_workflow.py b/posthog/temporal/data_modeling/run_workflow.py
index 7abf269e224f..ca90567bcd75 100644
--- a/posthog/temporal/data_modeling/run_workflow.py
+++ b/posthog/temporal/data_modeling/run_workflow.py
@@ -73,6 +73,7 @@ from products.data_warehouse.backend.data_load.create_table import create_table_
from products.data_warehouse.backend.data_load.saved_query_service import a_pause_saved_query_schedule
from products.data_warehouse.backend.s3 import ensure_bucket_exists, get_s3_client
from products.endpoints.backend.rate_limit import set_endpoint_materialization_ready
+from products.endpoints.backend.services.endpoint_materialization_service import prepare_executable_query
from products.warehouse_sources.backend.models.table import DataWarehouseTable
LOGGER = get_logger(__name__)
@@ -355,6 +356,8 @@ async def handle_model_ready(
team = await database_sync_to_async(Team.objects.get)(id=team_id)
saved_query = await get_saved_query(team, model.label)
+ if saved_query.origin == DataWarehouseSavedQuery.Origin.ENDPOINT:
+ await database_sync_to_async(prepare_executable_query)(saved_query)
await materialize_model(model.label, team, saved_query, job, logger)
ducklake_model = DuckLakeCopyModelInput(