Store baseline counts and fix dataset-aware reruns - #24
Merged
Conversation
…cy counts n_dayof already told a consumer how many day-of measurements a group had; there was no companion for the baseline window, so anything needing both re-derived them by aggregating events_with_as_and_geoloc itself. The dashboard did that on every page load -- 8 GiB for a 7-day range, 84 GiB for 90 days, against a table of 10.4 billion rows -- and did it on a coarser key (short city) than the detector groups on, which is the same pooling that let a 6-measurement group pass a 20-measurement threshold on its neighbours' totals. - dayof_counts becomes group_counts and emits both counts from ONE pass, with the window split moved from WHERE into COUNTIF. No new scan of the partition: the reference count to events_with_as_and_geoloc is unchanged at 7. - n_baseline is threaded through resolved/unresolved/combined to final_result and added to the INSERT column list, last, matching where ALTER TABLE ADD COLUMN puts it on the live tables. - add_n_baseline_column.sql joins bootstrap_tables.DDL_FILES. This is load bearing: create_events_explained_daily.sql is CREATE TABLE IF NOT EXISTS, a no-op on the existing table, so nothing else would ever add the column and step 07's INSERT would fail against it. - verify_group_identity check 4 now also flags a NULL n_baseline. Zero is a legitimate value there (a group with no trailing measurements), so only NULL counts as a fault. Verified against hermes_union 2026-08-12: the refactored COUNTIF reproduces the stored n_dayof on 2728 of 2728 rows, zero disagreements, zero unmatched. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Burdantes
marked this pull request as ready for review
August 15, 2026 13:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
n_baselinecount alongsiden_dayofin Step 07 without adding another partition scan.Why
The original Step 0 branch was squash-merged in #23, then these two follow-up commits were added to that already-merged branch. Reusing it made GitHub compare the pre-squash history again and produced merge conflicts. This PR reapplies only the two new commits on current
main.Impact
Consumers can use detector-aligned stored sufficiency counts instead of recomputing them from the large event partition. Reruns now target the requested dataset safely.
Validation
git diff --checkpassed.