Skip to content

Commit

Permalink
utilize unnested ntd_agency_info_key as ntd_id value for dim_organiza…
Browse files Browse the repository at this point in the history
…tion rows prior to cutover date
  • Loading branch information
charlie-costanzo committed Feb 21, 2025
1 parent e95607a commit dcc871a
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
11 changes: 1 addition & 10 deletions warehouse/models/mart/transit_database/dim_organizations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ WITH dim AS (
SELECT * FROM {{ ref('int_transit_database__organizations_dim') }}
),

-- This is deprecated, what replaced the source of truth for ntd_id < '2023-05-23' that was previously found in ntd_to_org.ntd_id ??
-- ntd_agency_to_organization AS (
-- SELECT * FROM {{ ref('_deprecated__ntd_agency_to_organization') }}
-- ),

dim_organizations AS (
SELECT
key,
Expand All @@ -31,10 +26,8 @@ dim_organizations AS (
-- use same May 23, 2023 cutover date as `assessment_status` --> `public_currently_operating` in downstream models for consistency
CASE
WHEN _valid_from >= '2023-05-23' THEN raw_ntd_id
ELSE ntd_to_org.ntd_id
ELSE ntd_agency_info_key
END AS ntd_id,

-- is this not related to ntd_to_org.ntd_id (ntd_id < '2023-05-23') ??
ntd_id_2022,
public_currently_operating,
public_currently_operating_fixed_route,
Expand All @@ -43,8 +36,6 @@ dim_organizations AS (
_valid_to

FROM dim
LEFT JOIN ntd_agency_to_organization ntd_to_org
ON source_record_id = ntd_to_org.organization_record_id
)

SELECT * FROM dim_organizations
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ stg_transit_database__organizations AS (
public_currently_operating_fixed_route = "Yes" AS public_currently_operating_fixed_route,
FROM once_daily_organizations
LEFT JOIN UNNEST(once_daily_organizations.ntd_id) as unnested_ntd_records

)

SELECT * FROM stg_transit_database__organizations

0 comments on commit dcc871a

Please sign in to comment.