diff --git a/backend/models.py b/backend/models.py index 314fe59..a83bcb7 100644 --- a/backend/models.py +++ b/backend/models.py @@ -24,6 +24,7 @@ class DimSchool(Base): religious_character = Column(String(100)) gender = Column(String(20)) age_range = Column(String(20)) + has_sixth_form = Column(Boolean) capacity = Column(Integer) total_pupils = Column(Integer) headteacher_name = Column(String(200)) diff --git a/pipeline/transform/models/marts/_marts_schema.yml b/pipeline/transform/models/marts/_marts_schema.yml index 7fb0201..a575a95 100644 --- a/pipeline/transform/models/marts/_marts_schema.yml +++ b/pipeline/transform/models/marts/_marts_schema.yml @@ -16,6 +16,17 @@ models: tests: - not_null: severity: warn + - name: has_sixth_form + description: > + Authoritative sixth-form flag from GIAS OfficialSixthForm. + "Has a sixth form" => true; "Does not have a sixth form" and + "Not applicable" => false; blank GIAS value falls back to + statutory_high_age >= 18. Replaces the age_range-contains-"18" + heuristic (spec 2026-07-07 §3). + tests: + - not_null + - accepted_values: + values: [true, false] - name: status tests: - accepted_values: diff --git a/pipeline/transform/models/marts/dim_school.sql b/pipeline/transform/models/marts/dim_school.sql index fba0296..a09a016 100644 --- a/pipeline/transform/models/marts/dim_school.sql +++ b/pipeline/transform/models/marts/dim_school.sql @@ -52,6 +52,14 @@ select s.religious_character, s.gender, s.statutory_low_age || '-' || s.statutory_high_age as age_range, + -- Authoritative sixth-form flag (spec §3): GIAS OfficialSixthForm. + -- "Not applicable" (nurseries, primaries, PRUs) => false. Blank GIAS + -- value (rare, new establishments) falls back to the statutory age range. + case + when s.official_sixth_form = 'Has a sixth form' then true + when s.official_sixth_form in ('Does not have a sixth form', 'Not applicable') then false + else coalesce(s.statutory_high_age >= 18, false) + end as has_sixth_form, s.capacity, s.total_pupils, concat_ws(' ', s.head_title, s.head_first_name, s.head_last_name) as headteacher_name,