test(dbt): fail the build when a published year loads empty (C2, H2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
59dd20ab00
commit
242c603aec
3 files changed
+41
No files matched your search
@@ -0,0 +1,16 @@
|
||||
-- Where a year's KS2 school information loaded (pupil counts present), its
|
||||
-- percentages loaded too. DfE's files give a disadvantaged % for 96–97% of
|
||||
-- those schools; 2023/24 loaded none because the file writes "34%" (audit
|
||||
-- C2). A year without an information file (2022/23) has no pupil counts and
|
||||
-- is skipped.
|
||||
|
||||
select
|
||||
year,
|
||||
count(total_pupils) as with_pupils,
|
||||
count(*) filter (where total_pupils is not null and disadvantaged_pct is not null)
|
||||
as with_disadvantaged
|
||||
from {{ ref('stg_ees_ks2') }}
|
||||
group by year
|
||||
having count(total_pupils) >= 1000
|
||||
and count(*) filter (where total_pupils is not null and disadvantaged_pct is not null)
|
||||
< 0.9 * count(total_pupils)
|
||||
@@ -0,0 +1,13 @@
|
||||
-- DfE publishes an average for about 152 LAs a year. Fewer than 145 in the
|
||||
-- latest year (or none at all) means the LA filter in tap_uk_ees
|
||||
-- (ks4_summary.headline_rows) stopped matching, e.g. after DfE renamed a label.
|
||||
|
||||
with latest as (
|
||||
select max(year) as year from {{ ref('fact_ks4_la_averages') }}
|
||||
)
|
||||
|
||||
select l.year, count(f.la_code) as las
|
||||
from latest l
|
||||
left join {{ ref('fact_ks4_la_averages') }} f on f.year = l.year
|
||||
group by l.year
|
||||
having count(f.la_code) < 145
|
||||
@@ -0,0 +1,12 @@
|
||||
-- Every year loaded from EES has an Attainment 8 for at least half its
|
||||
-- schools. DfE's files reach 82% each year; 2023/24 loaded at 0% after DfE
|
||||
-- re-issued its file under older column names (audit C2). Pre-2019 years come
|
||||
-- from stg_legacy_ks4 and are not checked here.
|
||||
|
||||
select
|
||||
year,
|
||||
count(*) as schools,
|
||||
count(attainment_8_score) as with_attainment_8
|
||||
from {{ ref('stg_ees_ks4') }}
|
||||
group by year
|
||||
having count(attainment_8_score) < 0.5 * count(*)
|
||||
Reference in new issue
Block a user