diff --git a/pipeline/transform/tests/assert_ks2_info_percentages_loaded.sql b/pipeline/transform/tests/assert_ks2_info_percentages_loaded.sql new file mode 100644 index 0000000..c994dea --- /dev/null +++ b/pipeline/transform/tests/assert_ks2_info_percentages_loaded.sql @@ -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) diff --git a/pipeline/transform/tests/assert_ks4_la_averages_cover_las.sql b/pipeline/transform/tests/assert_ks4_la_averages_cover_las.sql new file mode 100644 index 0000000..bad12df --- /dev/null +++ b/pipeline/transform/tests/assert_ks4_la_averages_cover_las.sql @@ -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 diff --git a/pipeline/transform/tests/assert_ks4_years_have_results.sql b/pipeline/transform/tests/assert_ks4_years_have_results.sql new file mode 100644 index 0000000..04b9df2 --- /dev/null +++ b/pipeline/transform/tests/assert_ks4_years_have_results.sql @@ -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(*)