Skip to content

Commit 8e0bf47

Browse files
author
V
committed
feat(dim_organizations): adds ntd_id_2022 column
1 parent d5c7c80 commit 8e0bf47

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

warehouse/models/mart/transit_database/_mart_transit_database.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,14 @@ models:
7979
description: |
8080
The organization's ID in the National Transit Database / FTA agency ID number.
8181
Data entry processes / sources of truth for this field have changed over time.
82-
As of May 2023, the source is the `raw_ntd_id` field in the Airtable `organizations` table;
82+
As of May 2023, the source is the `raw_ntd_id` field in the Airtable `organizations` table
83+
which is derived from 2021 ntd ids;
8384
for records before May 2023, sources were some combination of the `NTD agency info` table in
8485
Airtable and the `ntd_agency_to_organizations` CSV seed file in this dbt project (now
8586
renamed to `_deprecated__ntd_agency_to_organizations`).
87+
- name: ntd_id_2022
88+
description: |
89+
Just pulls out the 5 digit component of the raw_ntd_id
8690
- name: name
8791
description: Organization name
8892
- name: organization_type

warehouse/models/mart/transit_database/dim_organizations.sql

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ dim_organizations AS (
3232
WHEN _valid_from >= '2023-05-23' THEN raw_ntd_id
3333
ELSE ntd_to_org.ntd_id
3434
END AS ntd_id,
35+
IF(LENGTH(ntd_id) >= 10,
36+
SUBSTR(ntd_id, -5),
37+
ntd_id) AS ntd_id_2022,
3538
public_currently_operating,
3639
public_currently_operating_fixed_route,
37-
3840
_is_current,
3941
_valid_from,
4042
_valid_to

0 commit comments

Comments
 (0)