feat(dbt): dim_school.inspectorate and ofsted_listed (H4)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
TudorandClaude Opus 5.5 committed 2026-10-13 21:26:42 +01:00
1 parent 6cc135ec58
commit 8e82e2e4cf
6 files changed
+101 -7

No files matched your search

@@ -0,0 +1,21 @@
-- Intermediate model: every URN Ofsted's own data lists, inspected or not
-- (audit H4). Only these may be called "Not yet inspected". Reads the raw
-- school MI because stg_ofsted_inspections drops rows with no inspection date.
with school_mi as (
select distinct cast(urn as integer) as urn
from {{ source('raw', 'ofsted_inspections') }}
where urn is not null
),
fe as (
select distinct g.urn
from {{ ref('stg_gias_ukprn') }} g
join {{ ref('stg_ofsted_fe_providers') }} p
on p.provider_urn = g.urn
or (g.ukprn is not null and p.provider_ukprn = g.ukprn)
)
select urn from school_mi
union
select urn from fe
@@ -0,0 +1,29 @@
version: 2
unit_tests:
- name: int_ofsted_listed_includes_uninspected_schools_and_fe_providers
description: >
Abbas and Templecombe (150031) is in Ofsted's school MI with no inspection;
Exeter and North Devon Colleges Group (130645) is in the FE MI with none;
a UKPRN-only FE match counts too. A school in neither is absent (audit H4).
model: int_ofsted_listed
given:
- input: source('raw', 'ofsted_inspections')
rows:
- {urn: '150031', inspection_date: 'NULL'}
- {urn: '102408', inspection_date: '17/06/2025'}
- input: ref('stg_gias_ukprn')
rows:
- {urn: 130645, ukprn: null}
- {urn: 5, ukprn: '10099999'}
- {urn: 133058, ukprn: null}
- input: ref('stg_ofsted_fe_providers')
rows:
- {provider_urn: 130645, provider_ukprn: null}
- {provider_urn: 9999999, provider_ukprn: '10099999'}
expect:
rows:
- {urn: 150031}
- {urn: 102408}
- {urn: 130645}
- {urn: 5}