Skip to content

Commit 8946e87

Browse files
authored
Merge branch 'main' into vb-3305-gtfs-schedule-validator-v50-update
2 parents 1446f4f + 87d81b8 commit 8946e87

File tree

4 files changed

+42
-8
lines changed

4 files changed

+42
-8
lines changed

warehouse/models/intermediate/ntd_validation/int_ntd_rr20_service_3ratios_wide.sql

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,4 @@
1-
-- DECLARE check_period STRING;
2-
-- SET check_period = CONCAT(EXTRACT(YEAR from CURRENT_DATE()), ", ", EXTRACT(YEAR from CURRENT_DATE()) - 1);
3-
4-
-- DECLARE query STRING;
5-
-- SET query = CONCAT(
6-
with longform as (
1+
with longform as (
72
select
83
organization,
94
-- CAST(fiscal_year as STRING) as fiscal_year,

warehouse/models/intermediate/ntd_validation/int_ntd_validation.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ models:
1414
For NTD validation error ID #s RR20F-070, RR20F-065, RR20F-068, RR20F-066, RR20F-013
1515
- name: int_ntd_rr20_financial_total_exp
1616
description: |
17-
Setting up the RR-20 data for comparing totals, for operating and capital expenses, reported in different ares of the RR-20
17+
Setting up the RR-20 data for comparing totals, for operating and capital expenses, reported in different areas of the RR-20
1818
For NTD validation error ID #s RR20F-001OA, RR20F-001C, RR20F-182
1919
- name: int_ntd_rr20_service_1alldata
2020
description: |

warehouse/models/mart/ntd_validation/_mart_ntd_validation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ models:
55
description: |
66
Runs validation checks on the RR-20 service data. Source data is int_ntd_rr20_service_3ratios_wide.
77
NOTE: This model uses "this_year" and "last_year" as dynamic variables based on the date on which it is run.
8+
For NTD validation error ID #s rr20f_005, rr20f_146, rr20f_139, rr20f_008, rr20f_137, rr20f_154, rr20f_179, rr20f_171, rr20f_143
89
- name: fct_ntd_a30_vomscheck
910
description: |
1011
Runs various checks on VOMS data submitted to NTD, that are also in the file voms_inventory_check.py.

warehouse/models/mart/ntd_validation/fct_ntd_rr20_service_checks.sql

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ rr20f_179 as (
128128
rr20f_139 as (
129129
select
130130
organization,
131-
"RR20F-139: Vehicle Revenue Miles change" as name_of_check,
131+
"RR20F-139: Vehicle Revenue Miles (VRM) % change" as name_of_check,
132132
mode,
133133
{{this_year}} as year_of_data,
134134
CASE WHEN (vrm_{{this_year}} IS NULL OR vrm_{{this_year}} = 0 ) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") AS DATE) THEN "Did Not Run"
@@ -287,6 +287,40 @@ rr20f_171 as (
287287
"" as Agency_Response,
288288
CURRENT_TIMESTAMP() AS date_checked
289289
from {{ ref('int_ntd_rr20_service_3ratios_wide') }}
290+
),
291+
rr20f_143 as (
292+
select
293+
organization,
294+
"RR20F-143: Vehicle Revenue Miles (VRM) change from zero" as name_of_check,
295+
mode,
296+
{{this_year}} as year_of_data,
297+
CASE WHEN (ROUND(vrm_{{this_year}}) =0 AND ROUND(vrm_{{last_year}}) != 0 AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) > CAST(CONCAT({{this_year}}, "-10-31") AS DATE))
298+
OR (ROUND(vrm_{{this_year}}) !=0 AND ROUND(vrm_{{this_year}}) IS NOT NULL AND ROUND(voms_{{last_year}}) = 0)
299+
THEN "Fail"
300+
WHEN (vrm_{{this_year}} IS NULL OR vrm_{{this_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") AS DATE)
301+
THEN "Did Not Run"
302+
WHEN (vrm_{{last_year}} IS NULL OR vrm_{{last_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{last_year}}, "-10-31") AS DATE)
303+
THEN "Did Not Run"
304+
ELSE "Pass"
305+
END as check_status,
306+
CONCAT({{this_year}}, " = ", CAST(ROUND(vrm_{{this_year}}) AS STRING),
307+
", ", {{last_year}}, " = ", CAST(ROUND(vrm_{{last_year}}) AS STRING),
308+
"chg = ",
309+
CAST(ROUND((ROUND(vrm_{{this_year}},1) - ROUND(vrm_{{last_year}},1))/ABS(ROUND(vrm_{{this_year}},1)) * 100,1) AS STRING),
310+
"%"
311+
) as value_checked,
312+
CASE WHEN (ROUND(vrm_{{this_year}}) =0 AND ROUND(vrm_{{last_year}}) != 0 AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) > CAST(CONCAT({{this_year}}, "-10-31") AS DATE))
313+
OR (ROUND(vrm_{{this_year}}) !=0 AND ROUND(vrm_{{this_year}}) IS NOT NULL AND ROUND(vrm_{{last_year}}) = 0)
314+
THEN "The Vehicle Revenue Miles (VRM) for this mode has changed either to or from 0 compared to last year, please provide a narrative justification."
315+
WHEN (vrm_{{this_year}} IS NULL OR vrm_{{this_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") AS DATE)
316+
THEN CONCAT("No data but this check was run before the NTD submission due date in ",{{this_year}}, " for VOMS.")
317+
WHEN (vrm_{{last_year}} IS NULL OR vrm_{{last_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{last_year}}, "-10-31") AS DATE)
318+
THEN CONCAT("No data but this check was run before the NTD submission due date in ",{{last_year}}, " for VOMS.")
319+
ELSE ""
320+
END AS description,
321+
"" as Agency_Response,
322+
CURRENT_TIMESTAMP() AS date_checked
323+
from {{ ref('int_ntd_rr20_service_3ratios_wide') }}
290324
)
291325

292326

@@ -319,3 +353,7 @@ SELECT * FROM rr20f_179
319353
UNION ALL
320354

321355
SELECT * FROM rr20f_171
356+
357+
UNION ALL
358+
359+
SELECT * FROM rr20f_143

0 commit comments

Comments
 (0)