Skip to content

Commit ea3e019

Browse files
committed
update stop times grouped and fix some yaml column names
1 parent 2d45a7d commit ea3e019

File tree

3 files changed

+71
-20
lines changed

3 files changed

+71
-20
lines changed

warehouse/models/docs/gtfs schedule/stop_time_enum_aggregations.md warehouse/models/docs/gtfs schedule/stop_times_grouped.md

+29
Original file line numberDiff line numberDiff line change
@@ -120,3 +120,32 @@ Count of stop events on this trip where `departure_time` is populated.
120120

121121
See https://gtfs.org/reference/static#stop_timestxt for the raw data definitions.
122122
{% enddocs %}
123+
124+
{% docs column_flexible_trip %}
125+
Boolean indicator for whether this is a flexible trip defined using GTFS-Flex.
126+
GTFS-Flex flexible trips are indicated by using the fields `start_pickup_drop_off_window`and `end_pickup_drop_off_window` for at least some of their stop events.
127+
This means there is some flexible service without fixed schedules and this is not an entirely fixed-route trip.
128+
129+
Note that there may be some demand-responsive behavior on trips where this column is `false`; for example, there can be stops where a phone call to the agency is required to arrange pickup/drop off, which will be indicated in pickup/drop off type columns even if they are not included as "flexible" in this column.
130+
{% enddocs %}
131+
132+
{% docs column_fully_flexible_trip %}
133+
This is the same as `flexible_trip` except that the boolean here indicates that all (rather than just some) of the stop events had `start_pickup_drop_off_window` and `end_pickup_drop_off_window` populated, indicating that this is an entirely flexible/demand-responsive trip.
134+
{% enddocs %}
135+
136+
{% docs column_num_flexible_stop_events %}
137+
Count of stop events for this trip with `start_pickup_drop_off_window` and `end_pickup_drop_off_window` populated indicating flexible behavior.
138+
See `flexible_trip` for more information.
139+
{% enddocs %}
140+
141+
{% docs column_first_start_pickup_drop_off_window_sec %}
142+
Earliest value of `start_pickup_drop_off_window_sec` for this trip. Only populated for flexible trips.
143+
144+
Represents the number of seconds after 12 hours before noon (usually midnight) at which flexible pickups/drop offs begin for the earliest flexible stop on this trip.
145+
{% enddocs %}
146+
147+
{% docs column_last_end_pickup_drop_off_window_sec %}
148+
Latest value of `end_pickup_drop_off_window_sec` for this trip. Only populated for flexible trips.
149+
150+
Represents the number of seconds after 12 hours before noon (usually midnight) at which flexible pickups/drop offs end for final flexible stop on this trip.
151+
{% enddocs %}

warehouse/models/intermediate/gtfs/_int_gtfs.yaml

+30-20
Original file line numberDiff line numberDiff line change
@@ -293,45 +293,55 @@ models:
293293
The time zone of the final stop in this trip, pulled from dim_stops.
294294
For time of day categorization purposes, it is recommended to use `trip_start_timezone`
295295
rather than this.
296-
- name: ct_regularly_scheduled_pickup_stops
296+
- name: flexible_trip
297+
description: '{{ doc("column_flexible_trip") }}'
298+
- name: fully_flexible_trip
299+
description: '{{ doc("column_fully_flexible_trip") }}'
300+
- name: num_flexible_stop_events
301+
description: '{{ doc("column_num_flexible_stop_events") }}'
302+
- name: first_start_pickup_drop_off_window_sec
303+
description: '{{ doc("column_first_start_pickup_drop_off_window_sec") }}'
304+
- name: last_end_pickup_drop_off_window_sec
305+
description: '{{ doc("column_last_end_pickup_drop_off_window_sec") }}'
306+
- name: num_regularly_scheduled_pickup_stops
297307
description: '{{ doc("column_num_regularly_scheduled_pickup_stop_events") }}'
298-
- name: ct_no_pickup_stops
308+
- name: num_no_pickup_stops
299309
description: '{{ doc("column_num_no_pickup_stop_events") }}'
300-
- name: ct_phone_call_required_for_pickup_stops
310+
- name: num_phone_call_required_for_pickup_stops
301311
description: '{{ doc("column_num_phone_call_required_for_pickup_stop_events") }}'
302-
- name: ct_coordinate_pickup_with_driver_stops
312+
- name: num_coordinate_pickup_with_driver_stops
303313
description: '{{ doc("column_num_coordinate_pickup_with_driver_stop_events") }}'
304-
- name: ct_regularly_scheduled_drop_off_stops
314+
- name: num_regularly_scheduled_drop_off_stops
305315
description: '{{ doc("column_num_regularly_scheduled_drop_off_stop_events") }}'
306-
- name: ct_no_drop_off_stops
316+
- name: num_no_drop_off_stops
307317
description: '{{ doc("column_num_no_drop_off_stop_events") }}'
308-
- name: ct_phone_call_required_for_drop_off_stops
318+
- name: num_phone_call_required_for_drop_off_stops
309319
description: '{{ doc("column_num_phone_call_required_for_drop_off_stop_events") }}'
310-
- name: ct_coordinate_drop_off_with_driver_stops
320+
- name: num_coordinate_drop_off_with_driver_stops
311321
description: '{{ doc("column_num_coordinate_drop_off_with_driver_stop_events") }}'
312-
- name: ct_continuous_pickup_stops
322+
- name: num_continuous_pickup_stops
313323
description: '{{ doc("column_num_continuous_pickup_stop_events") }}'
314-
- name: ct_no_continuous_pickup_stops
324+
- name: num_no_continuous_pickup_stops
315325
description: '{{ doc("column_num_no_continuous_pickup_stop_events") }}'
316-
- name: ct_phone_call_required_for_continuous_pickup_stops
326+
- name: num_phone_call_required_for_continuous_pickup_stops
317327
description: '{{ doc("column_num_phone_call_required_for_continuous_pickup_stop_events") }}'
318-
- name: ct_coordinate_continuous_pickup_with_driver_stops
328+
- name: num_coordinate_continuous_pickup_with_driver_stops
319329
description: '{{ doc("column_num_coordinate_continuous_pickup_with_driver_stop_events") }}'
320-
- name: ct_continuous_drop_off_stops
330+
- name: num_continuous_drop_off_stops
321331
description: '{{ doc("column_num_continuous_drop_off_stop_events") }}'
322-
- name: ct_no_drop_off_stops
332+
- name: num_no_drop_off_stops
323333
description: '{{ doc("column_num_no_drop_off_stop_events") }}'
324-
- name: ct_phone_call_required_for_continuous_drop_off_stops
334+
- name: num_phone_call_required_for_continuous_drop_off_stops
325335
description: '{{ doc("column_num_phone_call_required_for_continuous_drop_off_stop_events") }}'
326-
- name: ct_coordinate_continuous_drop_off_with_driver_stops
336+
- name: num_coordinate_continuous_drop_off_with_driver_stops
327337
description: '{{ doc("column_num_coordinate_continuous_drop_off_with_driver_stop_events") }}'
328-
- name: ct_approximate_timepoint_stops
338+
- name: num_approximate_timepoint_stops
329339
description: '{{ doc("column_num_approximate_timepoint_stop_events") }}'
330-
- name: ct_exact_timepoint_stops
340+
- name: num_exact_timepoint_stops
331341
description: '{{ doc("column_num_exact_timepoint_stop_events") }}'
332-
- name: ct_arrival_times_populated
342+
- name: num_arrival_times_populated
333343
description: '{{ doc("column_num_arrival_times_populated_stop_events") }}'
334-
- name: ct_departure_times_populated
344+
- name: num_departure_times_populated
335345
description: '{{ doc("column_num_departure_times_populated_stop_events") }}'
336346
- name: int_gtfs_rt__distinct_download_configs
337347
description: |

warehouse/models/intermediate/gtfs/int_gtfs_schedule__stop_times_grouped.sql

+12
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ int_gtfs_schedule__stop_times_grouped AS (
7676
LOGICAL_OR(
7777
frequencies_defined_trip
7878
) AS frequencies_defined_trip,
79+
-- per: https://docs.google.com/spreadsheets/d/1iqvzJV_YWmFyYGtpbO2dqGMbf4XEjvar3rt9SxHU-xY/edit#gid=0
80+
-- determine flex usage by presence of these two fields for any row in stop times
81+
LOGICAL_OR(
82+
start_pickup_drop_off_window IS NOT NULL
83+
AND end_pickup_drop_off_window IS NOT NULL) AS flexible_trip,
84+
LOGICAL_AND(
85+
start_pickup_drop_off_window IS NOT NULL
86+
AND end_pickup_drop_off_window IS NOT NULL) AS fully_flexible_trip,
87+
COUNTIF(start_pickup_drop_off_window IS NOT NULL
88+
AND end_pickup_drop_off_window IS NOT NULL) AS num_flexible_stop_events,
89+
MIN(start_pickup_drop_off_window_sec) AS first_start_pickup_drop_off_window_sec,
90+
MAX(end_pickup_drop_off_window_sec) AS last_end_pickup_drop_off_window_sec,
7991

8092
-- see: https://gtfs.org/schedule/reference/#stop_timestxt for the enum definitions on the following fields
8193
-- including default value definitions

0 commit comments

Comments
 (0)