diff --git a/index.js b/index.js index 0a8a394..5daf8e4 100644 --- a/index.js +++ b/index.js @@ -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')) { diff --git a/lib/stop_times.js b/lib/stop_times.js index a2ad1c9..ba49db2 100644 --- a/lib/stop_times.js +++ b/lib/stop_times.js @@ -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 ) @@ -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