Skip to content

Commit

Permalink
Fix primary key for fct_monthly_route_service_by_timeofday (#3302)
Browse files Browse the repository at this point in the history
* add columns in group by to key

* add route_short_name, route_long_name to docs, swap order to match order of columns

* text wrapping
  • Loading branch information
tiffanychu90 authored Mar 15, 2024
1 parent 9c3ac72 commit 0e047a8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
22 changes: 14 additions & 8 deletions warehouse/models/mart/gtfs/_mart_gtfs_fcts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2094,7 +2094,8 @@ models:
columns:
- name: key
description: |
Synthetic primary key constructed from `base64_url`, `route_id`, `month`, and `year`.
Synthetic primary key constructed from `base64_url`, `route_id`, `month`,
and `year`.
tests: *primary_key_tests
- name: source_record_id
description: |
Expand All @@ -2118,14 +2119,17 @@ models:
to look up feed and GTFS dataset attributes.
- name: pt_array
description: |
Array of points describing this shape, looked up from `dim_shapes_arrays` via `shape_array_key`.
Array of points describing this shape, looked up from `dim_shapes_arrays`
via `shape_array_key`.
- name: fct_monthly_route_service_by_timeofday
description: |
An aggregation of GTFS schedule service by day and time characteristics.
columns:
- name: key
description: |
Synthetic primary key constructed from `source_record_id`, `route_id`, `month`, `year`, and `time_of_day`.
Synthetic primary key constructed from `source_record_id`, `route_id`,
`route_short_name`, `route_long_name`, `time_of_day`, `month`, `year`,
and `day_type`.
tests: *primary_key_tests
- name: name
- name: source_record_id
Expand All @@ -2143,12 +2147,14 @@ models:
Actual calendar year (Pacific Time dates) in which this service was scheduled to occur.
- name: day_type
description: |
Actual calendar day type (Pacific Time dates) in which this service was scheduled to occur.
This means that overnight service is associated with the calendar date on which it was scheduled,
even if it was associated with the prior `service_date` by the agency.
Actual calendar day type (Pacific Time dates) in which this service was scheduled to
occur (Monday, Tuesday, etc).
This means that overnight service is associated with the calendar date on which it was
scheduled, even if it was associated with the prior `service_date` by the agency.
- name: n_trips
description: |
Total trips that occurred for the route for this month and `time_of_day`.
Total trips that occurred for the route for this month, `day_type` and `time_of_day`.
- name: ttl_service_hours
description: |
Total scheduled service hours that occurred for the route for this month and `time_of_day`.
Total scheduled service hours that occurred for the route for this month, `day_type`,
and `time_of_day`.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ daypart_aggregations AS (

fct_monthly_route_service_by_timeofday AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['source_record_id', 'route_id', 'month', 'year', 'time_of_day']) }} AS key,
{{ dbt_utils.generate_surrogate_key(['source_record_id', 'route_id', 'route_short_name', 'route_long_name', 'time_of_day', 'month', 'year', 'day_type']) }} AS key,
name,
source_record_id,
route_id,
Expand Down

0 comments on commit 0e047a8

Please sign in to comment.