From e34525c1a4115b97a98fbf92bb4ed68a54d64fea Mon Sep 17 00:00:00 2001 From: zuhdil Date: Thu, 14 May 2026 14:37:36 +0700 Subject: [PATCH] Project `dedicated_to_women_or_children` onto `dim_priority` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the Two-Options field `crc8b_dedicatedtowomenorchildren` (already carried through bronze→silver automatically) to the gold layer's `dim_priority` as `dedicated_to_women_or_children`, resolved to its "Yes"/"No" label via the standard `OPTIONSET:` resolver — the same pattern used for `dim_candidate_core.test_format` (commit 6ce3ad8). Unblocks the dashboard's "Share of priorities dedicated to women or children" card, which has been a placeholder waiting on this column. Non-obvious choice: projected as a label rather than as a raw 0/1 integer. The dashboard already types other category fields on dimensions as strings, and rendering "Yes"/"No" lets the frontend stay boilerplate-free (no integer→label mapping table on that side). Distribution in the current Gold DB is 34 Yes / 31 No / 1 null across the 66 priorities. --- .../silver_to_gold/config/schema_map.py | 1 + tests/e2e/test_silver_to_gold_e2e.py | 20 +++++++++++++++++++ tests/unit/test_silver_to_gold.py | 16 +++++++++++++++ 3 files changed, 37 insertions(+) diff --git a/src/igh_data_transform/transformations/silver_to_gold/config/schema_map.py b/src/igh_data_transform/transformations/silver_to_gold/config/schema_map.py index c649115..9d6ea3d 100644 --- a/src/igh_data_transform/transformations/silver_to_gold/config/schema_map.py +++ b/src/igh_data_transform/transformations/silver_to_gold/config/schema_map.py @@ -167,6 +167,7 @@ "efficacy": "efficacy", "safety": "safety", "source": "source", + "dedicated_to_women_or_children": "OPTIONSET:crc8b_dedicatedtowomenorchildren", }, "dim_developer": { "_source_table": "vin_candidates", diff --git a/tests/e2e/test_silver_to_gold_e2e.py b/tests/e2e/test_silver_to_gold_e2e.py index 9997ed0..4376d2b 100644 --- a/tests/e2e/test_silver_to_gold_e2e.py +++ b/tests/e2e/test_silver_to_gold_e2e.py @@ -195,6 +195,26 @@ def test_dim_disease_has_expected_columns(self, gold_conn): missing = expected - cols assert not missing, f"Missing columns: {missing}" + # -- dim_priority -- + + def test_dim_priority_dedicated_to_women_or_children_is_label(self, gold_conn): + """`dedicated_to_women_or_children` holds the Two-Options label + ("Yes"/"No"), not the raw integer code (0/1). Numeric-only values + would indicate the OPTIONSET resolver was bypassed.""" + df = _read_table(gold_conn, "dim_priority") + assert "dedicated_to_women_or_children" in df.columns, ( + "dim_priority missing dedicated_to_women_or_children column" + ) + non_null = df["dedicated_to_women_or_children"].dropna() + if non_null.empty: + pytest.skip( + "No non-null dedicated_to_women_or_children rows in current data" + ) + # The label set is closed: Two-Options always resolves to {Yes, No}. + assert set(non_null.astype(str).unique()) <= {"Yes", "No"}, ( + f"Unexpected labels: {set(non_null.astype(str).unique())}" + ) + # -- dim_geography -- def test_dim_geography_has_iso_code(self, gold_conn): diff --git a/tests/unit/test_silver_to_gold.py b/tests/unit/test_silver_to_gold.py index 2339a6b..a13872c 100644 --- a/tests/unit/test_silver_to_gold.py +++ b/tests/unit/test_silver_to_gold.py @@ -74,3 +74,19 @@ def test_test_format_uses_optionset_resolution(self) -> None: STAR_SCHEMA_MAP["dim_candidate_core"]["test_format"] == "OPTIONSET:testformat" ) + + def test_dedicated_to_women_or_children_uses_optionset_resolution( + self, + ) -> None: + """`dim_priority.dedicated_to_women_or_children` resolves the + Two-Options code (0/1) to its label (No/Yes) via the OPTIONSET + cache, so the dashboard reads readable strings instead of raw + Dataverse codes — same pattern as `test_format`.""" + from igh_data_transform.transformations.silver_to_gold.config.schema_map import ( # noqa: E501 + STAR_SCHEMA_MAP, + ) + + assert ( + STAR_SCHEMA_MAP["dim_priority"]["dedicated_to_women_or_children"] + == "OPTIONSET:crc8b_dedicatedtowomenorchildren" + )