fix(dbt): read percentages DfE writes as "34%" (C2)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
242c603aec
commit
4ae3853277
2 files changed
+25
-1
No files matched your search
@@ -3,7 +3,9 @@
|
||||
Casts a string column to numeric, treating any non-numeric value as NULL.
|
||||
Handles all EES suppression codes (z, c, x, q, u, etc.) without needing
|
||||
an explicit list — any string that doesn't look like a number becomes NULL.
|
||||
A trailing percent sign is accepted: DfE's 2023/24 KS2 information file
|
||||
writes percentages as "34%" (audit C2).
|
||||
#}
|
||||
{% macro safe_numeric(col) -%}
|
||||
CASE WHEN {{ col }} ~ '^-?[0-9]+(\.[0-9]+)?$' THEN {{ col }}::numeric ELSE NULL END
|
||||
CASE WHEN {{ col }} ~ '^-?[0-9]+(\.[0-9]+)?%?$' THEN rtrim({{ col }}, '%')::numeric ELSE NULL END
|
||||
{%- endmacro %}
|
||||
Reference in new issue
Block a user