PR Checks / Frontend Typecheck + Tests (pull_request) Successful in 1m2s
PR Checks / Backend Smoke (pull_request) Successful in 7s
PR Checks / Build Backend (no push) (pull_request) Successful in 10s
PR Checks / Build Frontend (no push) (pull_request) Successful in 45s
PR Checks / Build Pipeline (no push) (pull_request) Successful in 38s
PR Checks / AI Code Review (Claude) (pull_request) Successful in 54s
Beechwood College (URN 142458, Sully, CF64 5SE) survived the England-only filter. GIAS types it a Special post 16 institution (32), not a Welsh establishment (30), so filtering on establishment type alone left it behind — the last Welsh school on the site, and the reason Vale of Glamorgan was still in the authority list. The earlier verification claimed the type codes mapped onto the Welsh authorities in both directions. That was checked exhaustively for Cardiff and by count for three others; Vale of Glamorgan was never checked, and it was the one that did not hold. LA code is the reliable discriminator: GIAS gives the 22 Welsh unitary authorities the contiguous block 660-681, which English authorities never use. Filtering on postcode would have been wrong — Redbrook, Tutshill, Wyedean and two other Gloucestershire schools carry NP16/NP25 postcodes because Royal Mail areas straddle the border, and they are English schools with English data. An e2e test now pins those five so the fix cannot be simplified into a postcode filter later. The 660-681 range is documented GIAS structure this project cannot verify from its own data, so the range filters and the authority NAME checks: if the range is ever wrong, a Welsh authority reappears in assert_england_only_schools and the pipeline fails loudly. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015mWQnpye9F299NVRCCSRvj
42 lines
1.8 KiB
SQL
42 lines
1.8 KiB
SQL
-- Mart: School location dimension — one row per URN, PostGIS-enabled
|
|
-- Geometry derived from GIAS easting/northing (British National Grid → WGS84).
|
|
-- For schools missing easting/northing, the geocode script backfills via Postcodes.io.
|
|
|
|
select
|
|
s.urn,
|
|
s.address_line1,
|
|
s.address_line2,
|
|
s.town,
|
|
s.county,
|
|
s.postcode,
|
|
s.local_authority_code,
|
|
s.local_authority_name,
|
|
s.parliamentary_constituency,
|
|
s.urban_rural,
|
|
s.easting,
|
|
s.northing,
|
|
case
|
|
when s.easting is not null and s.northing is not null
|
|
then ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326)
|
|
else null
|
|
end as geom,
|
|
case
|
|
when s.easting is not null and s.northing is not null
|
|
then ST_Y(ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326))
|
|
else null
|
|
end as latitude,
|
|
case
|
|
when s.easting is not null and s.northing is not null
|
|
then ST_X(ST_Transform(ST_SetSRID(ST_MakePoint(s.easting::double precision, s.northing::double precision), 27700), 4326))
|
|
else null
|
|
end as longitude
|
|
from {{ ref('stg_gias_establishments') }} s
|
|
-- Must match dim_school's status and England filters exactly (the API
|
|
-- inner-joins the two).
|
|
where s.status_code in (1, 3)
|
|
-- coalesce, not a bare NOT IN: a null type code would make the predicate
|
|
-- null and drop the row silently. Unknown type is not grounds for exclusion.
|
|
and coalesce(s.school_type_code, -1) not in ({{ var('non_england_school_type_codes') | join(', ') }})
|
|
-- Welsh schools GIAS does not type as Welsh establishments (see vars).
|
|
and coalesce(s.local_authority_code, -1) not between {{ var('welsh_la_code_min') }} and {{ var('welsh_la_code_max') }}
|