fix(db): switch :schema_gtfs with :schema in db/sql/gtfs-join-trats.sql

This commit is contained in:
dancingCycle 2023-08-29 13:23:09 +02:00
parent 079407dbf8
commit 306aa0a6aa
2 changed files with 2 additions and 43 deletions

View File

@ -13,9 +13,9 @@ CREATE INDEX IF NOT EXISTS trips_id_idx ON :schema_gtfs.trips(trip_id);
VACUUM ANALYZE;
CREATE TABLE IF NOT EXISTS :schema_gtfs.gtfs_join_trats AS SELECT trips.trip_id, trips.trip_headsign, routes.route_id, routes.route_short_name, agency.agency_id, agency.agency_name, stops.stop_id, stops.stop_name FROM :schema_gtfs.trips AS trips JOIN :schema_gtfs.routes AS routes ON trips.route_id = routes.route_id JOIN :schema_gtfs.agency AS agency ON routes.agency_id = agency.agency_id JOIN :schema_gtfs.stop_times AS times ON trips.trip_id = times.trip_id JOIN :schema_gtfs.stops AS stops ON times.stop_id = stops.stop_id ORDER BY stops.stop_id, routes.route_id, trips.trip_id;
CREATE TABLE IF NOT EXISTS :schema.gtfs_join_trats AS SELECT trips.trip_id, trips.trip_headsign, routes.route_id, routes.route_short_name, agency.agency_id, agency.agency_name, stops.stop_id, stops.stop_name FROM :schema_gtfs.trips AS trips JOIN :schema_gtfs.routes AS routes ON trips.route_id = routes.route_id JOIN :schema_gtfs.agency AS agency ON routes.agency_id = agency.agency_id JOIN :schema_gtfs.stop_times AS times ON trips.trip_id = times.trip_id JOIN :schema_gtfs.stops AS stops ON times.stop_id = stops.stop_id ORDER BY stops.stop_id, routes.route_id, trips.trip_id;
CREATE INDEX IF NOT EXISTS gtfs_join_trats_stop_id_idx ON :schema_gtfs.gtfs_join_trats(stop_id);
CREATE INDEX IF NOT EXISTS gtfs_join_trats_stop_id_idx ON :schema.gtfs_join_trats(stop_id);
VACUUM ANALYZE;

View File

@ -1,41 +0,0 @@
DROP TABLE IF EXISTS test_gtfs.join_srta;
CREATE INDEX IF NOT EXISTS agency_id_idx ON test_gtfs.agency(agency_id);
CREATE INDEX IF NOT EXISTS routes_id_idx ON test_gtfs.routes(route_id);
CREATE INDEX IF NOT EXISTS stop_tms_stop_id_idx ON test_gtfs.stop_times(stop_id);
CREATE INDEX IF NOT EXISTS stop_tms_trip_id_idx ON test_gtfs.stop_times(trip_id);
CREATE INDEX IF NOT EXISTS stops_id_idx ON test_gtfs.stops(stop_id);
CREATE INDEX IF NOT EXISTS trips_id_idx ON test_gtfs.trips(trip_id);
VACUUM ANALYZE;
CREATE TABLE IF NOT EXISTS test_gtfs.join_srta AS SELECT trips.trip_id, trips.trip_headsign, routes.route_id, routes.route_short_name, agency.agency_id, agency.agency_name, stops.stop_id, stops.stop_name FROM test_gtfs.trips AS trips JOIN test_gtfs.routes AS routes ON trips.route_id = routes.route_id JOIN test_gtfs.agency AS agency ON routes.agency_id = agency.agency_id JOIN test_gtfs.stop_times AS times ON trips.trip_id = times.trip_id JOIN test_gtfs.stops AS stops ON times.stop_id = stops.stop_id ORDER BY stops.stop_id, routes.route_id, trips.trip_id;
CREATE INDEX IF NOT EXISTS join_srta_stop_id_idx ON test_gtfs.join_srta(stop_id);
VACUUM ANALYZE;
---@rms-consult.de
SELECT count(*) FROM test_gtfs.join_srta WHERE stop_id LIKE '%de:08111:2420%';
SELECT stop_id, route_id, trip_id, route_short_name, agency_name FROM test_gtfs.join_srta WHERE stop_id LIKE '%de:08111:2420%';
SELECT * FROM test_gtfs.join_srta WHERE stop_id LIKE '%de:08111:2420%' LIMIT 10;
DROP TABLE IF EXISTS test_gtfs.join_srta_s_laihle;
CREATE TABLE IF NOT EXISTS test_gtfs.join_srta_s_laihle AS SELECT * FROM test_gtfs.join_srta WHERE stop_id LIKE '%de:08111:2420%';
SELECT count(*) FROM test_gtfs.join_srta_s_laihle;
SELECT * FROM test_gtfs.join_srta_s_laihle;
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (SELECT * FROM test_gtfs.join_srta_s_laihle) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/test_gtfs.join.srta_s_laihle.csv
---@vrn.de>
SELECT count(*) FROM test_gtfs.join_srta WHERE stop_name LIKE '%Tadano Demag%';
SELECT * FROM test_gtfs.join_srta WHERE stop_name LIKE '%Tadano Demag%' LIMIT 10;
DROP TABLE IF EXISTS test_gtfs.join_srta_zw_tadano_demag;
CREATE TABLE IF NOT EXISTS test_gtfs.join_srta_zw_tadano_demag AS SELECT * FROM test_gtfs.join_srta WHERE stop_name LIKE '%Tadano Demag%';
SELECT count(*) FROM test_gtfs.join_srta_zw_tadano_demag;
SELECT * FROM test_gtfs.join_srta_zw_tadano_demag LIMIT 10;
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (SELECT * FROM test_gtfs.join_srta_zw_tadano_demag) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/test_gtfs.join_srta_zw_tadano_demag.csv
---@vmt-thueringen.de
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (SELECT * FROM test_gtfs.join_srta) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/test_gtfs.join_srta.csv
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (select * from (select count(stop_id) as count_id, count(stop_id) filter (where stop_id not like '%:%:%') as count_no_dhid, count(stop_id) filter (where stop_id like '%:%:%') as count_dhid, stop_name from test_analysis.tbl_gtfs_stops_de_th group by stop_name order by count_id) as foo where count_id != count_dhid and count_id != count_no_dhid) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/tbl_gtfs_stops_de_th_mix.csv
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (select * from (select count(stop_id) as count_id, count(stop_id) filter (where stop_id not like '%:%:%') as count_no_dhid, count(stop_id) filter (where stop_id like '%:%:%') as count_dhid, stop_name from test_analysis.tbl_gtfs_stops_de_th group by stop_name order by count_id) as foo where count_id = count_dhid) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/tbl_gtfs_stops_de_th_dhid.csv
---psql -h localhost -p 5432 -U sib00_delfi -d sib00_delfi -c "COPY (select * from (select count(stop_id) as count_id, count(stop_id) filter (where stop_id not like '%:%:%') as count_no_dhid, count(stop_id) filter (where stop_id like '%:%:%') as count_dhid, stop_name from test_analysis.tbl_gtfs_stops_de_th group by stop_name order by count_id) as foo where count_id = count_no_dhid) TO STDOUT WITH CSV HEADER;" -o ~/Downloads/tbl_gtfs_stops_de_th_no_dhid.csv