fix(dim_school): infer phase from age range for independent schools
All checks were successful
Build and Push Docker Images / Build Backend (FastAPI) (push) Successful in 12s
Build and Push Docker Images / Build Frontend (Next.js) (push) Successful in 50s
Build and Push Docker Images / Build Pipeline (Meltano + dbt + Airflow) (push) Successful in 1m9s
Build and Push Docker Images / Trigger Portainer Update (push) Successful in 1s

Independent schools have phase='Not applicable' in GIAS. Now infer
phase from statutory age range: <=11 → Primary, >=11 → Secondary,
spans both → All-through. Falls back to original value if no age data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Tudor Sitaru
2026-04-01 16:18:52 +01:00
parent d591d8e66b
commit 4c3c3c882d

View File

@@ -14,7 +14,14 @@ select
s.urn, s.urn,
s.local_authority_code * 1000 + s.establishment_number as laestab, s.local_authority_code * 1000 + s.establishment_number as laestab,
s.school_name, s.school_name,
s.phase, case
when s.phase is not null and s.phase != 'Not applicable' then s.phase
when s.statutory_high_age is not null and s.statutory_high_age <= 11 then 'Primary'
when s.statutory_low_age is not null and s.statutory_low_age >= 11 then 'Secondary'
when s.statutory_low_age is not null and s.statutory_high_age is not null
and s.statutory_low_age < 11 and s.statutory_high_age > 11 then 'All-through'
else s.phase
end as phase,
s.school_type, s.school_type,
s.academy_trust_name, s.academy_trust_name,
s.academy_trust_uid, s.academy_trust_uid,