From 7724fe35030e7f0ce84166e674f50fb0804be9f9 Mon Sep 17 00:00:00 2001 From: Tudor Date: Fri, 27 Mar 2026 18:21:30 +0000 Subject: [PATCH] fix(stg_ofsted_inspections): correctly filter NULL string inspection dates The string 'NULL' is not SQL NULL, so the WHERE in the renamed CTE passed those rows through. Filter on the raw value using nullif in the CTE and on the computed date in the outer SELECT. Co-Authored-By: Claude Sonnet 4.6 --- pipeline/transform/models/staging/stg_ofsted_inspections.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pipeline/transform/models/staging/stg_ofsted_inspections.sql b/pipeline/transform/models/staging/stg_ofsted_inspections.sql index 9a22b65..100e6e1 100644 --- a/pipeline/transform/models/staging/stg_ofsted_inspections.sql +++ b/pipeline/transform/models/staging/stg_ofsted_inspections.sql @@ -36,7 +36,8 @@ renamed as ( report_url from source where urn is not null - and inspection_date is not null + and nullif(trim(inspection_date), 'NULL') is not null ) select * from renamed +where inspection_date is not null