Skip to content

Commit a839e50

Browse files
committed
deduplicate nysdec permit records
1 parent 3be4af6 commit a839e50

File tree

3 files changed

+20
-12
lines changed

3 files changed

+20
-12
lines changed

products/green_fast_track/models/_sources.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ sources:
151151
columns:
152152
- name: dec_id
153153
tests:
154-
- unique
155154
- not_null
156155
- name: facility_name
157156
tests:
@@ -164,7 +163,6 @@ sources:
164163
columns:
165164
- name: dec_id
166165
tests:
167-
- unique
168166
- not_null
169167
- name: facility_name
170168
tests:
Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,19 @@
11
WITH source AS (
2-
SELECT *
3-
FROM {{ source('recipe_sources', 'nysdec_state_facility_permits') }}
2+
SELECT * FROM {{ source('recipe_sources', 'nysdec_state_facility_permits') }}
3+
),
4+
deduplicated AS (
5+
SELECT DISTINCT
6+
dec_id,
7+
facility_name,
8+
geom
9+
FROM source
410
),
5-
611
final AS (
712
SELECT
813
'state_facility_permits' AS variable_type,
914
dec_id AS variable_id,
1015
facility_name,
1116
ST_TRANSFORM(geom::geometry, 2263) AS permit_geom
12-
FROM source
17+
FROM deduplicated
1318
)
14-
1519
SELECT * FROM final
Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
WITH source AS (
2-
SELECT *
3-
FROM {{ source('recipe_sources', 'nysdec_title_v_facility_permits') }}
2+
SELECT * FROM {{ source('recipe_sources', 'nysdec_title_v_facility_permits') }}
3+
),
4+
deduplicated AS (
5+
SELECT DISTINCT
6+
dec_id,
7+
facility_name,
8+
year,
9+
siccode,
10+
geom
11+
FROM source
412
),
5-
613
final AS (
714
SELECT
815
'title_v_permits' AS variable_type,
916
dec_id AS variable_id,
1017
st_transform(geom::geometry, 2263) AS permit_geom
11-
FROM source
18+
FROM deduplicated
1219
)
13-
1420
SELECT * FROM final

0 commit comments

Comments
 (0)