Skip to content

Commit

Permalink
#1051 sqlfluff
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielwol committed Dec 10, 2024
1 parent a0d6c84 commit 67ad34d
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions volumes/short_term_counting_program/sql/artery_assets_objectid.sql
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
CREATE OR REPLACE VIEW traffic.artery_assets
AS
WITH clpav18 AS (
SELECT
clpav.geo_id,
clpav.objectid,
WITH clpav18 AS (
SELECT
clpav.geo_id,
clpav.objectid,
row_number() OVER (PARTITION BY clpav.geo_id ORDER BY (SELECT clpav.geo_id)) AS rownumber
FROM gis_shared_streets.centreline_pavement_180430 AS clpav
)

SELECT
ad.arterycode,
ac.centreline_id,
SELECT
ad.arterycode,
ac.centreline_id,
clpav18.objectid
FROM traffic.arterydata AS ad
JOIN traffic.arteries_centreline AS ac USING (arterycode)
JOIN clpav18 ON clpav18.geo_id = ac.centreline_id AND clpav18.rownumber = 1;
JOIN clpav18
ON ac.centreline_id = clpav18.geo_id
AND clpav18.rownumber = 1;

COMMENT ON VIEW traffic.artery_assets IS 'Lookup between artery codes and objectid (to join pavement asset data e.g. vz_analysis.gcc_pavement_asset)';
ALTER TABLE IF EXISTS traffic.artery_assets
OWNER TO traffic_admins;
COMMENT ON VIEW traffic.artery_assets IS
'Lookup between artery codes and objectid '
'(to join pavement asset data e.g. vz_analysis.gcc_pavement_asset)';

ALTER TABLE IF EXISTS traffic.artery_assets OWNER TO traffic_admins;

GRANT ALL ON TABLE traffic.artery_assets TO bdit_humans;
GRANT ALL ON TABLE traffic.artery_assets TO traffic_admins;


-- flashcrow.counts.arteries_centreline must be migrated to the bigdata.traffic schema and copied over regularly
-- flashcrow.counts.arteries_centreline must be migrated to the bigdata.traffic schema
-- and copied over regularly
-- column arteries_centreline.centreline_id links to column centreline_pavement_180430.geo_id.
-- window function on gis_shared_streets.centreline_pavement_180430 is used to remove duplicates, keeping arterycode unique in the lookup table.
-- window function on gis_shared_streets.centreline_pavement_180430 is used to remove duplicates,
-- keeping arterycode unique in the lookup table.

0 comments on commit 67ad34d

Please sign in to comment.