Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions products/facilities/facdb/sql/pipelines/dcp_colp.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
(
Expand Down
4 changes: 4 additions & 0 deletions products/facilities/models/product/_product.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Original file line number Diff line number Diff line change
@@ -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 %}
Loading