: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-warehouse): report auto-detect repartition targets as 'auto' instead of null (#71055)
Tom Owers15ccea310399
diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/repartition_controller.pyindex 07fc821a3de7..fe84ad508388 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/repartition_controller.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/repartition_controller.py@@ -278,7 +278,11 @@ async def maybe_flag_for_repartition("max_partition_bytes_before": max_bytes,"trigger_reason": trigger_reason,"recent_oom_count": oom_count,- "partition_mode_after": target.partition_mode,+ # An unpartitioned table's target has mode None ("enable partitioning, auto-detect+ # the scheme on the first rewrite batch"). Emit an explicit "auto" so dashboards can+ # render the target scheme instead of a null — half of all flagged events are this+ # case, and a null here NULL-poisons any string built from the scheme properties.+ "partition_mode_after": target.partition_mode or "auto","partition_format_after": target.partition_format,"partition_count_after": target.partition_count,"partition_size_after": target.partition_size,diff --git a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test_repartition_controller.py b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test_repartition_controller.pyindex fc2ffb035def..62e25d4c9fb3 100644--- a/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test_repartition_controller.py+++ b/products/warehouse_sources/backend/temporal/data_imports/pipelines/pipeline/test_repartition_controller.py@@ -95,6 +95,27 @@ class TestRepartitionDetection:assert pending["trigger_reason"] == "proactive_threshold"assert capture.call_args.args[0] == "warehouse_repartition_flagged"+ def test_unpartitioned_table_flags_auto_target_scheme(self, team):+ # An unpartitioned table's target legitimately has mode None (auto-detect at rewrite time),+ # but the flagged event must report "auto" — a null here NULL-poisons dashboard strings —+ # while the pending target must keep mode None so the rewrite still auto-detects.+ schema = _make_schema(team, {"primary_key_columns": ["id"]})+ with tempfile.TemporaryDirectory() as d:+ delta = _write_unpartitioned_delta(f"{d}/t")+ with (+ patch.object(ctrl, "target_partition_bytes", return_value=1),+ patch.object(ctrl, "is_auto_repartition_enabled", return_value=True),+ patch.object(ctrl, "capture_repartition_event") as capture,+ ):+ self._detect(team, schema, delta)++ schema.refresh_from_db()+ pending = schema.repartition_pending+ assert pending is not None+ assert pending["partition_mode"] is None+ assert capture.call_args.args[0] == "warehouse_repartition_flagged"+ assert capture.call_args.args[1]["partition_mode_after"] == "auto"+def test_within_budget_records_size_but_does_not_flag(self, team):schema = _make_schema(team, {"partitioning_enabled": True, "partition_mode": "md5", "partition_count": 2})with tempfile.TemporaryDirectory() as d: