-- ailf.official_area_scores — per-area scores restricted to official runs
--
-- Joins ailf.area_scores (UNNESTed per-model per-area scores) to
-- ailf.official_runs on report_id so area-level trend dashboards
-- inherit the D0037 official-run predicate without re-declaring it.
--
-- Source: ailf.area_scores, ailf.official_runs
-- Target: ailf.official_area_scores (this view)
--
-- Usage:
--   bq query --use_legacy_sql=false < views/official_area_scores.sql
--
-- @see views/official_runs.sql
-- @see docs/decisions/D0037-run-classification-and-ownership-taxonomy.md

CREATE OR REPLACE VIEW `data-platform-302218.ailf.official_area_scores` AS
SELECT a.*
FROM   `data-platform-302218.ailf.area_scores` AS a
INNER JOIN `data-platform-302218.ailf.official_runs` AS r
       USING (report_id);
