-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remake dim_monthly_ntd_ridership_with_adjustments to
dim_monthly_ridership_with_adjustments (removed _ntd_). - Format SQL file and reorder columns - Remove irrelevant year column - Rename columns to follow the same pattern as the other new NTD models - Add surrogate key [#3519]
- Loading branch information
Showing
2 changed files
with
46 additions
and
39 deletions.
There are no files selected for viewing
39 changes: 0 additions & 39 deletions
39
warehouse/models/mart/ntd/dim_monthly_ntd_ridership_with_adjustments.sql
This file was deleted.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
warehouse/models/mart/ntd/dim_monthly_ridership_with_adjustments.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
{{ config(materialized="table") }} | ||
|
||
WITH | ||
source AS ( | ||
SELECT * FROM {{ ref("int_ntd__monthly_ridership_with_adjustments_joined") }} | ||
), | ||
|
||
ntd_modes AS ( | ||
SELECT * FROM {{ ref("int_ntd__modes") }} | ||
), | ||
|
||
dim_monthly_ridership_with_adjustments AS ( | ||
SELECT {{ dbt_utils.generate_surrogate_key(['ntd_id', 'mode', 'tos', 'period_month', 'period_year']) }} as key, | ||
ntd_id, | ||
legacy_ntd_id, | ||
agency, | ||
reporter_type, | ||
concat(period_year, '-', lpad(period_month, 2, '0')) AS period_year_month, | ||
period_year, | ||
period_month, | ||
uza_name AS primary_uza_name, | ||
uace_cd AS primary_uza_code, | ||
_3_mode, | ||
mode, | ||
ntd_mode_full_name AS mode_name, | ||
CASE | ||
WHEN mode IN ('AG', 'AR', 'CB', 'CC', 'CR', 'FB', 'HR', 'IP', 'IP', 'LR', 'MB', 'MG', 'MO', 'RB', 'SR', 'TB', 'TR', 'YR') | ||
THEN 'Fixed Route' | ||
WHEN mode IN ('DR', 'DT', 'VP', 'JT', 'PB') | ||
THEN 'Demand Response' | ||
ELSE 'Unknown' -- mode is null sometimes | ||
END AS service_type, | ||
mode_type_of_service_status, | ||
tos, | ||
upt, | ||
vrm, | ||
vrh, | ||
voms, | ||
_dt, | ||
execution_ts | ||
FROM source | ||
LEFT JOIN ntd_modes | ||
ON source.mode = ntd_modes.ntd_mode_abbreviation | ||
) | ||
|
||
SELECT * FROM dim_monthly_ridership_with_adjustments |