diff --git a/pipeline/transform/models/marts/_marts_schema.yml b/pipeline/transform/models/marts/_marts_schema.yml index a575a95..4b89d73 100644 --- a/pipeline/transform/models/marts/_marts_schema.yml +++ b/pipeline/transform/models/marts/_marts_schema.yml @@ -30,7 +30,7 @@ models: - name: status tests: - accepted_values: - values: ["Open"] + values: ["Open", "Open, but proposed to close"] - name: dim_location description: School location dimension with PostGIS geometry diff --git a/pipeline/transform/models/marts/dim_location.sql b/pipeline/transform/models/marts/dim_location.sql index be285a1..7c13c4b 100644 --- a/pipeline/transform/models/marts/dim_location.sql +++ b/pipeline/transform/models/marts/dim_location.sql @@ -31,4 +31,5 @@ select else null end as longitude from {{ ref('stg_gias_establishments') }} s -where s.status = 'Open' +-- Must match dim_school's status filter exactly (the API inner-joins the two). +where s.status in ('Open', 'Open, but proposed to close') diff --git a/pipeline/transform/models/marts/dim_school.sql b/pipeline/transform/models/marts/dim_school.sql index 0de54fa..fbcc8b1 100644 --- a/pipeline/transform/models/marts/dim_school.sql +++ b/pipeline/transform/models/marts/dim_school.sql @@ -91,4 +91,7 @@ from schools s {% if ofsted_relation is not none %} left join {{ ref('int_ofsted_latest') }} o on s.urn = o.urn {% endif %} -where s.status = 'Open' +-- "Open, but proposed to close" schools are still operating (pupils enrolled, +-- results published) — include them; they drop out automatically once GIAS +-- flips them to "Closed" (marts are fully rebuilt each run). +where s.status in ('Open', 'Open, but proposed to close')