diff --git a/products/facilities/facdb/sql/pipelines/dcp_colp.sql b/products/facilities/facdb/sql/pipelines/dcp_colp.sql index 489ef9bb57..763c4235e2 100644 --- a/products/facilities/facdb/sql/pipelines/dcp_colp.sql +++ b/products/facilities/facdb/sql/pipelines/dcp_colp.sql @@ -40,6 +40,7 @@ WITH _dcp_colp_tmp AS ( WHEN agency LIKE '%DEP%' AND usetype LIKE '%TESTING LABORATORY%' THEN 'Environmental Testing Laboratory' WHEN agency LIKE '%CUNY%' AND usetype LIKE '%RESIDENTIAL%' THEN 'University Residential Structure' WHEN agency LIKE '%HHC%' AND usetype LIKE '%RESIDENTIAL%' THEN 'Hospital Residential Structure' + WHEN agency LIKE '%HHC%' AND usetype LIKE '%EMERGENCY MEDICL STN%' THEN 'Emergency Medical Station' ELSE initcap(replace(usetype, 'OTHER ', '')) END ) AS factype, @@ -119,7 +120,8 @@ WITH _dcp_colp_tmp AS ( usetype LIKE '%TRANSIT%' AND usetype NOT LIKE '%TRANSITIONAL%' ) THEN 'Rail Yards and Maintenance' - WHEN usetype LIKE '%BUS%' THEN 'Bus Depots and Terminals' -- Health and Human + WHEN usetype LIKE '%BUS%' THEN 'Bus Depots and Terminals' + WHEN usetype LIKE '%EMERGENCY MEDICL STN%' THEN 'Other Emergency Services' WHEN agency LIKE '%HHC%' THEN 'Hospitals and Clinics' WHEN usetype LIKE '%HOSPITAL%' THEN 'Hospitals and Clinics' WHEN usetype LIKE '%AMBULATORY HEALTH%' THEN 'Hospitals and Clinics' @@ -203,7 +205,6 @@ WITH _dcp_colp_tmp AS ( AND usetype LIKE '%COURT%' THEN 'Courthouses and Judicial' WHEN agency LIKE '%CORR%' THEN 'Detention and Correctional' WHEN usetype LIKE '%AMBULANCE%' THEN 'Other Emergency Services' - WHEN usetype LIKE '%EMERGENCY MEDICAL%' THEN 'Other Emergency Services' WHEN usetype LIKE '%FIREHOUSE%' THEN 'Fire Services' WHEN usetype LIKE '%POLICE STATION%' THEN 'Police Services' WHEN @@ -332,6 +333,13 @@ WITH _dcp_colp_tmp AS ( WHEN agency = 'TBTA' THEN 'Metropolitan Transportation Authority' WHEN agency = 'TLC' THEN 'NYC Taxi and Limousine Commission' WHEN agency = 'UNKN' THEN 'NYC Unknown' + WHEN agency = 'BOC' THEN 'NYC Board of Correction' + WHEN agency = 'CNTYC' THEN 'County Clerk' + WHEN agency = 'DVS' THEN 'NYC Department of Veterans'' Services' + WHEN agency = 'EEPC' THEN 'NYC Equal Employment Practices Commission' + WHEN agency = 'NYS' THEN 'New York State' + WHEN agency = 'OTHP' THEN 'Other Public' + WHEN agency = 'RGB' THEN 'NYC Rent Guidelines Board' END ) AS opname, ( diff --git a/products/facilities/models/product/_product.yml b/products/facilities/models/product/_product.yml index b2b4cfaaf3..f6244b865b 100644 --- a/products/facilities/models/product/_product.yml +++ b/products/facilities/models/product/_product.yml @@ -18,3 +18,7 @@ models: parent_column: '"FACSUBGRP"' - name: '"FACSUBGRP"' tests: [ not_null ] + - name: '"OPNAME"' + tests: + - not_null_if_other_not_null: + other_column_name: '"OPABBREV"' diff --git a/products/facilities/tests/generic/not_null_if_other_not_null.sql b/products/facilities/tests/generic/not_null_if_other_not_null.sql new file mode 100644 index 0000000000..0377d6ab74 --- /dev/null +++ b/products/facilities/tests/generic/not_null_if_other_not_null.sql @@ -0,0 +1,9 @@ +{% test not_null_if_other_not_null(model, column_name, other_column_name) %} +-- Asserts that whenever `other_column_name` is not null, +-- `column_name` is also not null. +-- Fails on any row where `other_column_name` IS NOT NULL but `column_name` IS NULL. +select * +from {{ model }} +where {{ other_column_name }} is not null + and {{ column_name }} is null +{% endtest %}