Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ WITH
),

int_ntd__monthly_ridership_with_adjustments_upt AS (
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
legacy_ntd_id,
agency,
reporter_type,
split(period, '_')[offset(2)] AS period_year,
split(period, '_')[offset(1)] AS period_month,
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
SPLIT(period, '_')[OFFSET(1)] AS period_month,
uza_name,
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
mode,
mode_type_of_service_status,
_3_mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ WITH
),

int_ntd__monthly_ridership_with_adjustments_voms AS (
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
legacy_ntd_id,
agency,
reporter_type,
split(period, '_')[offset(2)] AS period_year,
split(period, '_')[offset(1)] AS period_month,
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
SPLIT(period, '_')[OFFSET(1)] AS period_month,
uza_name,
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
mode,
mode_type_of_service_status,
_3_mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ WITH
),

int_ntd__monthly_ridership_with_adjustments_vrh AS (
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
legacy_ntd_id,
agency,
reporter_type,
split(period, '_')[offset(2)] AS period_year,
split(period, '_')[offset(1)] AS period_month,
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
SPLIT(period, '_')[OFFSET(1)] AS period_month,
uza_name,
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
mode,
mode_type_of_service_status,
_3_mode,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@ WITH
),

int_ntd__monthly_ridership_with_adjustments_vrm AS (
SELECT format("%05d", cast(cast(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
SELECT FORMAT("%05d", CAST(CAST(ntd_id AS NUMERIC) AS INT64)) AS ntd_id,
legacy_ntd_id,
agency,
reporter_type,
split(period, '_')[offset(2)] AS period_year,
split(period, '_')[offset(1)] AS period_month,
SAFE_CAST(SPLIT(period, '_')[OFFSET(2)] AS INT64) AS period_year,
SPLIT(period, '_')[OFFSET(1)] AS period_month,
uza_name,
format("%05d", cast(uace_cd AS INT64)) AS uace_cd,
FORMAT("%05d", CAST(uace_cd AS INT64)) AS uace_cd,
mode,
mode_type_of_service_status,
_3_mode,
Expand Down
59 changes: 3 additions & 56 deletions warehouse/models/mart/ntd/dim_annual_agency_information.sql
Original file line number Diff line number Diff line change
@@ -1,61 +1,8 @@
{{ config(materialized='view') }}

WITH intermediate_unioned_agency_information AS (
SELECT *
FROM {{ ref('int_ntd__unioned_agency_information') }}
),

dim_annual_agency_information AS (
SELECT
key,
year,
ntd_id,
state_parent_ntd_id,
agency_name,
reporter_acronym,
doing_business_as,
division_department,
legacy_ntd_id,
reported_by_ntd_id,
reported_by_name,
reporter_type,
reporting_module,
organization_type,
subrecipient_type,
fy_end_date,
original_due_date,
address_line_1,
address_line_2,
p_o__box,
city,
state,
zip_code,
zip_code_ext,
region,
url,
fta_recipient_id,
ueid,
service_area_sq_miles,
service_area_pop,
primary_uza_code,
primary_uza_name,
tribal_area_name,
population,
density,
sq_miles,
voms_do,
voms_pt,
total_voms,
volunteer_drivers,
personal_vehicles,
tam_tier,
number_of_state_counties,
number_of_counties_with_service,
state_admin_funds_expended,
_valid_from,
_valid_to,
_is_current,
FROM intermediate_unioned_agency_information
-- This table is deprecated, and temporarily pulling from the new production table fct_monthly_ridership_with_adjustments
WITH dim_annual_agency_information AS (
SELECT * FROM {{ ref("dim_agency_information") }}
)

SELECT * FROM dim_annual_agency_information
Original file line number Diff line number Diff line change
@@ -1,46 +1,8 @@
{{ config(materialized="table") }}
{{ config(materialized='view') }}

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
)
-- This table is deprecated, and temporarily pulling from the new production table fct_monthly_ridership_with_adjustments
WITH dim_monthly_ridership_with_adjustments AS (
SELECT * FROM {{ ref("fct_monthly_ridership_with_adjustments") }}
)

SELECT * FROM dim_monthly_ridership_with_adjustments
Loading