From b0438dea01c5fd53030ae224e62eaa2f379bff43 Mon Sep 17 00:00:00 2001 From: Sam Calder-Mason Date: Mon, 23 Feb 2026 14:04:29 +1000 Subject: [PATCH] fix(reorg): break phantom depth feedback loop in reorg models The existing_depths CTE reads back all distinct depths from the output table, including rows with reorg_count=0. These zero-count rows feed back into the CROSS JOIN, causing every depth that ever existed to propagate to every day/hour forever. Filter existing_depths to only consider rows where reorg_count > 0, breaking the self-reinforcing cycle while still allowing one pass of zero-overwrite when a reorg legitimately disappears from the data. --- models/transformations/fct_reorg_daily.sql | 1 + models/transformations/fct_reorg_hourly.sql | 1 + 2 files changed, 2 insertions(+) diff --git a/models/transformations/fct_reorg_daily.sql b/models/transformations/fct_reorg_daily.sql index 602a5458..6c10d84a 100644 --- a/models/transformations/fct_reorg_daily.sql +++ b/models/transformations/fct_reorg_daily.sql @@ -88,6 +88,7 @@ WITH FROM `{{ .self.database }}`.`{{ .self.table }}` AS e FINAL INNER JOIN target_days d ON e.day_start_date = d.day_start_date + WHERE e.reorg_count > 0 ), depth_dim AS ( SELECT depth FROM existing_depths diff --git a/models/transformations/fct_reorg_hourly.sql b/models/transformations/fct_reorg_hourly.sql index fa0d5e75..7834fed7 100644 --- a/models/transformations/fct_reorg_hourly.sql +++ b/models/transformations/fct_reorg_hourly.sql @@ -90,6 +90,7 @@ WITH FROM `{{ .self.database }}`.`{{ .self.table }}` AS e FINAL INNER JOIN target_hours h ON e.hour_start_date_time = h.hour_start_date_time + WHERE e.reorg_count > 0 ), depth_dim AS ( SELECT depth FROM existing_depths