: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(managed-warehouse): use scene flag for registration (#84629)
Eric Duongaf5ee0827d5b
diff --git a/products/managed_warehouse/backend/README.md b/products/managed_warehouse/backend/README.mdindex f4ba7260d594..36c4e9783ac6 100644--- a/products/managed_warehouse/backend/README.md+++ b/products/managed_warehouse/backend/README.md@@ -102,15 +102,15 @@ This path currently supports Parquet only. Support for Azure Blob Storage, CSV,## Feature flag gating-Each workflow is gated by its own feature flag (evaluated via `feature_enabled`). Create or update the appropriate flag locally to target the team you are testing with—otherwise the copy workflow will be skipped even if the rest of the configuration is correct.+Each workflow evaluates a feature flag through `feature_enabled`. Create or update the appropriate flag locally. The copy flags target the project, while `data-warehouse-scene` targets the organization. Otherwise, the workflow will be skipped even if the rest of the configuration is correct.-| Workflow | Feature Flag |-| ------------------------ | --------------------------------------------- |-| Data Modeling | `ducklake-data-modeling-copy-workflow` |-| Data Imports | `ducklake-data-imports-copy-workflow` |-| Data Import Registration | `ducklake-data-imports-registration-workflow` |+| Workflow | Feature Flag |+| ------------------------ | -------------------------------------- |+| Data Modeling | `ducklake-data-modeling-copy-workflow` |+| Data Imports | `ducklake-data-imports-copy-workflow` |+| Data Import Registration | `data-warehouse-scene` |-The two data-import flags are independent and target the same stable DuckLake table. During rollout, enable only the intended path for a project; if both run for the same import, the last atomic table swap wins.+The data-import copy and registration paths target the same stable DuckLake table. An organization with `data-warehouse-scene` enabled runs registration. Disable `ducklake-data-imports-copy-workflow` for its projects to avoid both paths applying the same import. If both run, the last atomic table swap wins.## Data Ops workflow status@@ -200,7 +200,7 @@ Follow these checklists to exercise the DuckLake copy workflows on a local check### Testing Data Imports workflows1. **Start the dev stack**- Run `hogli start` (or `bin/start`) so Postgres, Duckgres, SeaweedFS, Temporal, and all DuckLake defaults are up. Enable either `ducklake-data-imports-copy-workflow` for the existing Delta-copy path or `ducklake-data-imports-registration-workflow` for the prepared-Parquet path.+ Run `hogli start` (or `bin/start`) so Postgres, Duckgres, SeaweedFS, Temporal, and all DuckLake defaults are up. Enable `data-warehouse-scene` for the prepared-Parquet path. Enable `ducklake-data-imports-copy-workflow` only when testing the existing Delta-copy path; both paths run when both flags are enabled.2. **Trigger a data import sync from the app**In the PostHog UI, open Data Warehouse → Sources, connect a source (e.g., Stripe, Hubspot), select the schemas to sync, and click **Sync**. This schedules the `external-data-job` workflow.diff --git a/products/managed_warehouse/backend/facade/feature_flags.py b/products/managed_warehouse/backend/facade/feature_flags.pyindex 5372db97ba17..22d4ba230d95 100644--- a/products/managed_warehouse/backend/facade/feature_flags.py+++ b/products/managed_warehouse/backend/facade/feature_flags.py@@ -9,6 +9,7 @@ if TYPE_CHECKING:logger = structlog.get_logger(__name__)+DATA_WAREHOUSE_SCENE_FLAG = "data-warehouse-scene"MANAGED_WAREHOUSE_SQL_EDITOR_FLAG = "managed-warehouse-sql-editor"MANAGED_WAREHOUSE_QUERY_STATUS_LABEL_PREFIX = f"{MANAGED_WAREHOUSE_SQL_EDITOR_FLAG}:"diff --git a/products/managed_warehouse/backend/presentation/views.py b/products/managed_warehouse/backend/presentation/views.pyindex ccc1c0f159f5..604625cb53e0 100644--- a/products/managed_warehouse/backend/presentation/views.py+++ b/products/managed_warehouse/backend/presentation/views.py@@ -25,9 +25,9 @@ from rest_framework.response import Responsefrom posthog.security.outbound_proxy import internal_requests-logger = structlog.get_logger(__name__)+from products.managed_warehouse.backend.facade.feature_flags import DATA_WAREHOUSE_SCENE_FLAG-DATA_WAREHOUSE_SCENE_FLAG = "data-warehouse-scene"+logger = structlog.get_logger(__name__)# The Postgres database to connect to is always "ducklake"; the user-chosen warehouse# name becomes the SNI subdomain (e.g. my-warehouse.dw.us.postwh.com) and the DNS zonediff --git a/products/managed_warehouse/backend/temporal/ducklake_register_data_imports_workflow.py b/products/managed_warehouse/backend/temporal/ducklake_register_data_imports_workflow.pyindex 6b0d412d8327..faf07a4b3ebf 100644--- a/products/managed_warehouse/backend/temporal/ducklake_register_data_imports_workflow.py+++ b/products/managed_warehouse/backend/temporal/ducklake_register_data_imports_workflow.py@@ -47,6 +47,7 @@ from products.managed_warehouse.backend.facade.contracts import (ManagedWarehouseSourceJobUpdate,ManagedWarehouseSourceJobWorkflow,)+from products.managed_warehouse.backend.facade.feature_flags import DATA_WAREHOUSE_SCENE_FLAGfrom products.managed_warehouse.backend.models import ManagedWarehouseSourceJobfrom products.managed_warehouse.backend.storage import connect_to_duckgres, setup_duckgres_sessionfrom products.managed_warehouse.backend.temporal.metrics import (@@ -64,7 +65,6 @@ from products.managed_warehouse.backend.temporal.source_job_state import record_from products.warehouse_sources.backend.facade.models import ExternalDataSchemaLOGGER = get_logger(__name__)-DUCKLAKE_DATA_IMPORTS_REGISTRATION_WORKFLOW_FLAG = "ducklake-data-imports-registration-workflow"DATA_IMPORTS_GENERATIONS_PREFIX = "_imports"DUCKLAKE_REGISTER_STAGE_DURATION_METRIC = "ducklake_register_data_imports_stage_duration"S3_COPY_BATCH_SIZE = 16@@ -225,23 +225,18 @@ async def ducklake_register_data_imports_gate_activity(inputs: DuckLakeRegisterDlogger = LOGGER.bind()try:- team = await database_sync_to_async(Team.objects.only("uuid", "organization_id").get)(id=inputs.team_id)+ team = await database_sync_to_async(Team.objects.only("organization_id").get)(id=inputs.team_id)except Team.DoesNotExist:await logger.aerror("Team does not exist when evaluating DuckLake data imports registration gate")return False+ organization_id = str(team.organization_id)try:flag_enabled = feature_enabled_or_false(- DUCKLAKE_DATA_IMPORTS_REGISTRATION_WORKFLOW_FLAG,- str(team.uuid),- groups={- "organization": str(team.organization_id),- "project": str(team.id),- },- group_properties={- "organization": {"id": str(team.organization_id)},- "project": {"id": str(team.id)},- },+ DATA_WAREHOUSE_SCENE_FLAG,+ organization_id,+ groups={"organization": organization_id},+ group_properties={"organization": {"id": organization_id}},only_evaluate_locally=True,send_feature_flag_events=False,)diff --git a/products/managed_warehouse/backend/tests/temporal/test_ducklake_register_data_imports_workflow.py b/products/managed_warehouse/backend/tests/temporal/test_ducklake_register_data_imports_workflow.pyindex c3cc1c3cb027..6bf626f65498 100644--- a/products/managed_warehouse/backend/tests/temporal/test_ducklake_register_data_imports_workflow.py+++ b/products/managed_warehouse/backend/tests/temporal/test_ducklake_register_data_imports_workflow.py@@ -14,7 +14,6 @@ from posthog.sync import database_sync_to_asyncfrom products.managed_warehouse.backend.facade.contracts import ManagedWarehouseSourceJobStatusfrom products.managed_warehouse.backend.temporal import ducklake_register_data_imports_workflow as registration_modulefrom products.managed_warehouse.backend.temporal.ducklake_register_data_imports_workflow import (- DUCKLAKE_DATA_IMPORTS_REGISTRATION_WORKFLOW_FLAG,S3_COPY_BATCH_SIZE,DuckLakeRegisterDataImportsActivityInputs,DuckLakeRegisterDataImportsGateInputs,@@ -52,7 +51,7 @@ def _cp_no_rows():@pytest.mark.asyncio@pytest.mark.django_db@pytest.mark.parametrize("flag_enabled", [True, False])-async def test_registration_gate_uses_independent_feature_flag(monkeypatch, ateam, flag_enabled):+async def test_registration_gate_uses_data_warehouse_scene_flag(monkeypatch, ateam, flag_enabled):captured: dict[str, object] = {}def fake_feature_enabled(key, distinct_id, **kwargs):@@ -64,12 +63,10 @@ async def test_registration_gate_uses_independent_feature_flag(monkeypatch, atearesult = await ducklake_register_data_imports_gate_activity(DuckLakeRegisterDataImportsGateInputs(team_id=ateam.id))assert result is flag_enabled- assert captured["key"] == DUCKLAKE_DATA_IMPORTS_REGISTRATION_WORKFLOW_FLAG- assert captured["distinct_id"] == str(ateam.uuid)- assert captured["groups"] == {- "organization": str(ateam.organization_id),- "project": str(ateam.id),- }+ assert captured["key"] == "data-warehouse-scene"+ assert captured["distinct_id"] == str(ateam.organization_id)+ assert captured["groups"] == {"organization": str(ateam.organization_id)}+ assert captured["group_properties"] == {"organization": {"id": str(ateam.organization_id)}}assert captured["only_evaluate_locally"] is Trueassert captured["send_feature_flag_events"] is False