-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add flag for shn to dim_stops_latest
- Loading branch information
1 parent
1ca1f38
commit ea4afaa
Showing
2 changed files
with
45 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 3 additions & 30 deletions
33
...house/models/staging/state_geoportal/stg_state_geoportal__state_highway_network_stops.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,16 @@ | ||
WITH external_state_geoportal__state_highway_network AS ( | ||
SELECT * | ||
FROM | ||
{{ source('external_state_geoportal', 'state_highway_network') }} | ||
`cal-itp-data-infra-staging.external_state_geoportal.state_highway_network` | ||
--{{ source('external_state_geoportal', 'state_highway_network') }} | ||
), | ||
|
||
get_latest_extract AS( | ||
stg_state_geoportal__state_highway_network_stops AS( | ||
|
||
SELECT * | ||
FROM external_state_geoportal__state_highway_network | ||
-- we pull the whole table every month in the pipeline, so this gets only the latest extract | ||
QUALIFY DENSE_RANK() OVER (ORDER BY execution_ts DESC) = 1 | ||
), | ||
|
||
buffer_geometry_table AS ( | ||
SELECT | ||
ST_BUFFER(wkt_coordinates, | ||
30.48) AS buffer_geometry | ||
FROM get_latest_extract | ||
), | ||
|
||
current_stops AS ( | ||
SELECT | ||
pt_geom, | ||
key | ||
FROM {{ ref('dim_stops_latest') }} | ||
), | ||
|
||
|
||
stops_on_shn AS ( | ||
SELECT | ||
current_stops.* | ||
FROM buffer_geometry_table, current_stops | ||
WHERE ST_DWITHIN( | ||
buffer_geometry_table.buffer_geometry,current_stops.pt_geom, 0) | ||
), | ||
|
||
stg_state_geoportal__state_highway_network_stops AS ( | ||
SELECT * | ||
FROM stops_on_shn | ||
) | ||
|
||
SELECT * FROM stg_state_geoportal__state_highway_network_stops |