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.

feat(managed-warehouse): enroll onboarding orgs in the Trino cell (#91098)

James Greenhilld6e04a0436b6
diff --git a/products/managed_warehouse/backend/presentation/views.py b/products/managed_warehouse/backend/presentation/views.py
index 97ae5c32da86..453a501afa3a 100644
--- a/products/managed_warehouse/backend/presentation/views.py
+++ b/products/managed_warehouse/backend/presentation/views.py
@@ -282,6 +282,14 @@ def provision(
"ducklake": {"enabled": True},
"metadata_store": {"type": "cnpg-shard"},
"data_store": {"type": "s3bucket"},
+ # Onboarding also enrolls the org in the shared Trino cell, so Trino is
+ # available as a compute engine over the same DuckLake catalog the duckgres
+ # server reads. The control plane writes the opt-in row inside the provision
+ # transaction and its provisioner claims the org into a cell on the next
+ # reconcile. Idempotent, so re-provisioning is safe; omitting the key (the
+ # behavior before this) means PG-only, which is not the same as sending
+ # enabled=false — that is also a no-op, never a disable.
+ "trino": {"enabled": True},
},
require_enabled=require_enabled,
)
diff --git a/products/managed_warehouse/backend/tests/api/test_presentation.py b/products/managed_warehouse/backend/tests/api/test_presentation.py
index 3df2370bc7c9..2969be366960 100644
--- a/products/managed_warehouse/backend/tests/api/test_presentation.py
+++ b/products/managed_warehouse/backend/tests/api/test_presentation.py
@@ -246,6 +246,31 @@ def test_provision_persists_duckgres_server_on_success(mock_request: MagicMock)
assert server.bucket_region is None
+@override_settings(CLOUD_DEPLOYMENT="US", DUCKGRES_PG_PORT=5432)
+@patch("products.managed_warehouse.backend.presentation.views._request")
+def test_provision_enrolls_the_org_in_the_trino_cell(mock_request: MagicMock) -> None:
+ """Onboarding opts the org into Trino so the cell can serve its catalog.
+
+ The control plane treats a missing "trino" key as PG-only, so the enrollment is
+ invisible unless the key is actually sent — assert on the request body rather
+ than on the response, which looks identical either way.
+ """
+ org = Organization.objects.create(name="Org")
+ team = Team.objects.create(organization=org)
+ mock_request.return_value = Response(
+ {"status": "provisioning started", "org": str(org.id), "username": "root", "password": "secret"},
+ status=202,
+ )
+
+ managed_warehouse.provision(org.id, "my-warehouse", team.id, "events")
+
+ # provision() also completes the first team's row, so it issues more than one
+ # control-plane call — pick the provision one rather than the most recent.
+ provision_call = next(c for c in mock_request.call_args_list if c.args[2] == "/provision")
+ assert provision_call.kwargs["json_body"]["trino"] == {"enabled": True}
+
+
@pytest.mark.django_db
def test_provision_captures_generation_before_request_and_skips_local_writes_if_activation_loses(
_onboarding_side_effects,