Skip to content

Add strict 2025 pipeline-inclusion flag to dim_candidate_core - #17

Merged
zuhdil merged 5 commits into
mainfrom
who-priority-strict-pipeline
Jun 16, 2026
Merged

Add strict 2025 pipeline-inclusion flag to dim_candidate_core#17
zuhdil merged 5 commits into
mainfrom
who-priority-strict-pipeline

Conversation

@zuhdil

@zuhdil zuhdil commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds a strict 2025 pipeline-inclusion flag to the candidate dimension, for the WHO Priority page's drill-down.

  • The bronze new_includeinpipeline column is the 2025 source-of-truth, but the existing gold fact_pipeline_snapshot.include_in_pipeline flag is forward-filled during temporal expansion — so a blank 2025 value can still read as "included". (34 candidates currently fall in this gap.)
  • Capture the raw 2025 value as a candidate-grain silver column includeinpipeline_2025_raw before _expand_temporal_rows consumes and drops new_includeinpipeline (and protect it through drop_empty_columns when all-null).
  • Map a new gold boolean dim_candidate_core.new_include_in_pipeline_2025 = CASE WHEN includeinpipeline_2025_raw = 100000000 THEN 1 ELSE 0 ENDYes-only; No, Pending and blank all map to 0.
  • Register the column in INTEGER_EXACT_NAMES so it gets INTEGER (not TEXT) affinity, since its name matches no INTEGER suffix.

The existing include_in_pipeline flag is left untouched, so every other page keeps its current behaviour.

Coordination

Paired with akvo/igh-dashboard#148 (the WHO page consumes this column). That PR bundles a rebuilt star_schema.db so it is self-contained for CI, but this ETL change is the source-of-truth for how the column is produced — merge this so future rebuilds carry it.

Test Plan

  • uv run pytest — 442 passed (unit incl. new candidate-capture + schema-map tests)
  • uv run pytest --e2e -k silver_to_gold — gold column present and strictly 0/1
  • Rebuilt star schema: strict active candidate count 2,338 → 2,304; all 2,304 map to bronze new_includeinpipeline = Yes, zero leak

zuhdil added 4 commits June 16, 2026 17:50
The WHO Priority page must count only candidates whose 2025
`new_includeinpipeline` is exactly Yes. The existing
`includeinpipeline` flag forward-fills from earlier years during
temporal expansion, so a blank 2025 value can still read as included.

Capture the raw 2025 value into a candidate-grain
`includeinpipeline_2025_raw` column before `_expand_temporal_rows`
consumes and drops `new_includeinpipeline`, so the gold layer can
derive a strict 2025-only flag.
drop_empty_columns would otherwise silently remove the new column when
every candidate's 2025 inclusion is blank (or the source column is
absent), leaving the gold layer to KeyError on a missing column. Add it
to the preserve list so the schema stays consistent, and cover the
all-null case with a test.

Tighten the existing grain test's `len(rows_a) >= 1` to `> 1` to
confirm the value fans out across all temporal rows for candidate id-1,
not just one.
Map the captured `includeinpipeline_2025_raw` to a new
`new_include_in_pipeline_2025` boolean that is 1 only when the 2025
value is exactly Yes. This is deliberately separate from the
forward-filled `include_in_pipeline` fact flag so existing pages keep
their behaviour while the WHO Priority page can filter strictly.
…core

Adds an e2e assertion that `new_include_in_pipeline_2025` exists in
`dim_candidate_core` and holds only integer 0/1 values after the full
bronze→silver→gold transform.

Running the test against the real bronze DB revealed that the column was
stored as TEXT ('0'/'1') rather than INTEGER. The DDL generator infers
column affinity by name suffix, but `new_include_in_pipeline_2025` does
not end in any of the known INTEGER suffixes (_key, _id, _flag, _count),
so it defaulted to TEXT. Adding it to `INTEGER_EXACT_NAMES` in
`ddl_generator.py` fixes the affinity, which also ensures the column
reads back as integers wherever the gold schema is queried in production.
CI runs `ruff format --check src/ tests/`; the long assert line in the
new dim_candidate_core strict-flag test exceeded the line length. Wrap
it to match the formatter.
@zuhdil
zuhdil merged commit bb7ff91 into main Jun 16, 2026
1 check passed
@zuhdil
zuhdil deleted the who-priority-strict-pipeline branch June 16, 2026 19:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant