-- Macro: Parse Ofsted Report Card grade (post-Nov 2025 framework) from text
-- into the 5-point scale. Real values confirmed via a live sample of the MI
-- CSV (see pipeline/scripts/diagnose_compare_gaps.py's
-- "TASK 7 VALUE SAMPLE 2026-07-12" note) -- unrecognised text (including the
-- 'NULL' sentinel used by the source CSV for blanks) parses to NULL, never
-- errors.

{% macro parse_report_card_grade(column_name) %}
    case lower(trim(nullif({{ column_name }}, 'NULL')))
        when 'exceptional' then 1
        when 'strong standard' then 2
        when 'expected standard' then 3
        when 'needs attention' then 4
        when 'urgent improvement' then 5
        else null
    end
{% endmacro %}
