Skip to content

ntd: fix failing tests #3991

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
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 @@ -36,6 +36,7 @@ WITH

int_ntd__asset_inventory_time_series_active_fleet AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
-- Extract the year number from the string (e.g., '_2021' -> 2021) and ensure it's an INT64
-- This is needed for proper comparison with dim_agency_information.year which is an INT64
SAFE_CAST(REGEXP_EXTRACT(year, r'_(\d+)') AS INT64) AS year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__asset_inventory_time_series_ada_fleet AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
-- Extract the year number from the string (e.g., '_2021' -> 2021) and ensure it's an INT64
-- This is needed for proper comparison with dim_agency_information.year which is an INT64
SAFE_CAST(REGEXP_EXTRACT(year, r'_(\d+)') AS INT64) AS year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__asset_inventory_time_series_avg_fleet_age AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
-- Extract the year number from the string (e.g., '_2021' -> 2021) and ensure it's an INT64
-- This is needed for proper comparison with dim_agency_information.year which is an INT64
SAFE_CAST(REGEXP_EXTRACT(year, r'_(\d+)') AS INT64) AS year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__asset_inventory_time_series_avg_seating_capacity AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
-- Extract the year number from the string (e.g., '_2021' -> 2021) and ensure it's an INT64
-- This is needed for proper comparison with dim_agency_information.year which is an INT64
SAFE_CAST(REGEXP_EXTRACT(year, r'_(\d+)') AS INT64) AS year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__asset_inventory_time_series_avg_standing_capacity AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
-- Extract the year number from the string (e.g., '_2021' -> 2021) and ensure it's an INT64
-- This is needed for proper comparison with dim_agency_information.year which is an INT64
SAFE_CAST(REGEXP_EXTRACT(year, r'_(\d+)') AS INT64) AS year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ WITH

int_ntd__capital_expenditures_time_series_facilities AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ WITH

int_ntd__capital_expenditures_time_series_other AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ WITH

int_ntd__capital_expenditures_time_series_rolling_stock AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ WITH

int_ntd__capital_expenditures_time_series_total AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_capital_federal AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_capital_local AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_capital_other AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_capital_state AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_capital_total AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_decommissioned_operatingfares AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
_2017_status,
agency_status,
uza_population,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_decommissioned_operatingother AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
_2017_status,
agency_status,
uza_population,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_operating_federal AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_operating_local AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_operating_other AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_operating_state AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ WITH

int_ntd__operating_and_capital_funding_time_series_operating_total AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_drm AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_fares AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_opexp_ga AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_opexp_nvm AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_opexp_total AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_opexp_vm AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_opexp_vo AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_pmt AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_upt AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_voms AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_vrh AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ WITH

int_ntd__service_data_and_operating_expenses_time_series_by_mode_vrm AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['ntd_id', 'year', 'legacy_ntd_id', 'mode', 'service']) }} AS key,
agency_name,
agency_status,
census_year,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_breakdowns AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_breakdowns_by_agency AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
WITH staging_capital_expenses_by_capital_use AS (
SELECT *
FROM {{ ref('stg_ntd__capital_expenses_by_capital_use') }}
-- remove bad rows for 'Advance Transit, Inc. NH' and 'Southern Teton Area Rapid Transit'
WHERE key NOT IN ('7b202e36d05a359ebe66c546fa2b0ad1','f39359b88ea57b16e325a2831ed81908','d1a170138bd1bc84702db21a32c8660c',
'b8cf03629eea7ea725cb80f2a6e9f0f5','7ad8ddc66e0b6d6716cf8e795ddf2c85','df732c77b7e728435f10b52c63054860',
'166f0664950cccf4af1eda5a5d489beb','10cb814290bf2e31bc81a2c7936d517a')
),

dim_agency_information AS (
Expand All @@ -17,7 +21,7 @@ dim_agency_information AS (

fct_capital_expenses_by_capital_use AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service', 'stg.form_type']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
WITH staging_capital_expenses_by_mode AS (
SELECT *
FROM {{ ref('stg_ntd__capital_expenses_by_mode') }}
-- remove bad rows for 'Advance Transit, Inc. NH' and 'Southern Teton Area Rapid Transit'
WHERE key NOT IN ('33c3d376e7d93b04c210041d62e015f2','1bebb98cd526881d0beab080dafd1e6a','1d5f79c7f06b68f023dd6513f8d797d4',
'f8b280fb1301a54725feefa098f519ec','9078bab61ab02779f9a4a5b043e377d9','1e9138bb433fed360f111c90866fc94a',
'e1503c0491fb6666f060aa64276fb707','faf75088d148925ea862051b49b54429')
),

dim_agency_information AS (
Expand All @@ -17,7 +21,7 @@ dim_agency_information AS (

fct_capital_expenses_by_mode AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_capital_expenses_for_existing_service AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_capital_expenses_for_expansion_of_service AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_employees_by_agency AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_employees_by_mode AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_employees_by_mode_and_employee_type AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service', 'stg.full_or_part_time']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_fuel_and_energy AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year', 'stg.mode', 'stg.type_of_service']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ dim_agency_information AS (

fct_fuel_and_energy_by_agency AS (
SELECT
{{ dbt_utils.generate_surrogate_key(['stg.ntd_id', 'stg.report_year']) }} AS key,
stg.key,
stg.ntd_id,
stg.report_year,

Expand Down
Loading
Loading