Skip to content

Commit 27cd146

Browse files
committed
chk
1 parent 774f025 commit 27cd146

15 files changed

+103
-5
lines changed

products/cscl/models/intermediate/adjacent_polygons/int__segment_atomicpolygons.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ WITH segment_offsets AS (
1010

1111
SELECT
1212
so.lionkey,
13+
so.globalid,
1314
so.segmentid,
1415
so.boroughcode AS segment_borocode,
1516
left_poly.atomicid AS left_atomicid,

products/cscl/models/intermediate/adjacent_polygons/int__segment_offsets.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ WITH segments AS (
88

99
SELECT
1010
lionkey,
11+
globalid,
1112
segmentid,
1213
boroughcode,
1314
feature_type,

products/cscl/models/intermediate/nodes/int__segments_to_nodes.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ config(
22
materialized = 'table',
33
indexes=[
4-
{'columns': ['segmentid']},
4+
{'columns': ['lionkey']},
55
{'columns': ['nodeid']},
66
]
77
) }}

products/cscl/models/intermediate/nodes/int__segments_with_nodes.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{{ config(
22
materialized = 'table',
33
indexes=[
4-
{'columns': ['segmentid']},
4+
{'columns': ['lionkey']},
55
]
66
) }}
77

products/cscl/models/intermediate/segments/int__primary_segments.sql

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,4 +112,3 @@ segment_attributes AS (
112112
)
113113

114114
SELECT * FROM segment_attributes
115-
WHERE face_code IS NOT NULL -- TODO error report for this and maybe refactor to get this in a more logical place

products/cscl/models/intermediate/segments/int__protosegments.sql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ SELECT
1818
CASE
1919
WHEN feature_type_codes.source_feature_class = 'centerline' THEN facecode.street_facecode
2020
ELSE facecode.feature_facecode
21-
END AS face_code, -- TODO error report when null
21+
END AS face_code,
2222
CASE
2323
WHEN feature_type_codes.source_feature_class <> 'nonstreetfeatures' THEN proto.alt_segment_seqnum
2424
ELSE seqnum.segment_seqnum
@@ -67,7 +67,7 @@ SELECT
6767
proto.source_table,
6868
proto.globalid
6969
FROM proto
70-
INNER JOIN primary_segments ON proto.segmentid = primary_segments.segmentid -- TODO error report for non-matches
70+
LEFT JOIN primary_segments ON proto.segmentid = primary_segments.segmentid
7171
LEFT JOIN facecode ON proto.b7sc = facecode.b7sc
7272
LEFT JOIN seqnum ON proto.globalid = seqnum.globalid
7373
LEFT JOIN feature_type_codes ON proto.feature_type_code IS NOT DISTINCT FROM feature_type_codes.code -- NULL -> centerline

products/cscl/models/intermediate/segments/int__segments.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ WITH segments AS (
1313
SELECT
1414
{{ dbt_utils.star(ref('int__primary_segments')) }}
1515
FROM {{ ref("int__protosegments") }}
16+
WHERE geom IS NOT NULL -- proxy for joined to a segment
1617
)
1718
SELECT
1819
CONCAT(boroughcode, face_code, segment_seqnum) AS lionkey,
1920
*
2021
FROM segments
22+
WHERE face_code IS NOT NULL
2123
ORDER BY lionkey
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{% set log_tables = dbt_utils.get_relations_by_pattern(
2+
table_pattern='log__%'
3+
) %}
4+
5+
{{ dbt_utils.union_relations(relations=log_tables) }}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
WITH lion AS (
2+
SELECT * FROM {{ ref("int__lion") }}
3+
),
4+
centerline AS (
5+
SELECT * FROM {{ ref("stg__centerline") }}
6+
),
7+
proto AS (
8+
SELECT * FROM {{ ref("stg__altsegmentdata_proto") }}
9+
),
10+
joined AS (
11+
SELECT
12+
lion.lionkey,
13+
lion.globalid,
14+
lion.segmentid,
15+
lion.segment_locational_status,
16+
CASE
17+
WHEN lion.source_table = 'centerline' THEN centerline.seglocstatus
18+
WHEN lion.source_table = 'altsegmentdata' THEN proto.seglocstatus
19+
END AS source_segment_locational_status,
20+
lion.source_table
21+
FROM lion
22+
LEFT JOIN centerline ON lion.source_table = 'centerline' AND lion.segmentid = centerline.segmentid
23+
LEFT JOIN proto ON lion.source_table = 'altsegmentdata' AND lion.ogc_fid = proto.ogc_fid
24+
)
25+
SELECT
26+
'seglocstatus mismatch' AS error,
27+
globalid,
28+
source_table,
29+
'segmentid' AS record_id_type,
30+
segmentid AS record_id
31+
FROM joined
32+
WHERE segment_locational_status IS DISTINCT FROM source_segment_locational_status
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
SELECT DISTINCT
2+
'protosegment without geometry-modeled segment' AS error,
3+
globalid
4+
source_table,
5+
'segmentid' AS record_id_type,
6+
segmentid AS record_id
7+
FROM {{ ref('int__protosegments') }}
8+
WHERE geom IS NULL

0 commit comments

Comments
 (0)