Skip to content

Commit

Permalink
agency handling: add todos
Browse files Browse the repository at this point in the history
  • Loading branch information
derhuerst committed Oct 31, 2024
1 parent 21d658e commit a8c3e95
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ LANGUAGE sql;
// https://github.com/google/transit/blame/217e9bf/gtfs/spec/en/reference.md#L544-L554
// However, because we have to use left join instead of an inner join in tables referencing `agency`, this prevents the PostgreSQL query planner from doing some filter pushdowns, e.g.
// - when querying `arrivals_departures` by route, stop, date and t_departure/t_arrival
// todo: add tests: 0 agencies (implicit single agency), 1 agency
{
let agencies = 0
for await (const agency of await readCsv('agency')) {
Expand Down
2 changes: 2 additions & 0 deletions lib/stop_times.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ WITH stop_times_based AS NOT MATERIALIZED (
LEFT JOIN "${opt.schema}".stops stations ON stops.parent_station = stations.stop_id
JOIN "${opt.schema}".trips ON s.trip_id = trips.trip_id
JOIN "${opt.schema}".routes ON trips.route_id = routes.route_id
-- todo: what if the route is missing (LEFT JOIN), does this work?
JOIN "${opt.schema}".agency ON routes.agency_id = agency.agency_id
JOIN "${opt.schema}".service_days ON trips.service_id = service_days.service_id
)
Expand Down Expand Up @@ -458,6 +459,7 @@ WITH stop_times_based AS NOT MATERIALIZED (
) AS to_wheelchair_boarding
FROM "${opt.schema}".trips
LEFT JOIN "${opt.schema}".routes ON trips.route_id = routes.route_id
-- todo: what if the route is missing (LEFT JOIN), does this work?
JOIN "${opt.schema}".agency ON routes.agency_id = agency.agency_id
LEFT JOIN "${opt.schema}".stop_times ON trips.trip_id = stop_times.trip_id
LEFT JOIN "${opt.schema}".stops from_stops ON stop_times.stop_id = from_stops.stop_id
Expand Down

0 comments on commit a8c3e95

Please sign in to comment.