Skip to content

Commit

Permalink
airtable: new fields & tables to address #1630
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurie Merrell committed Jul 13, 2022
1 parent dd83a0a commit 53dd5ca
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{{ config(materialized='table') }}

WITH latest_services AS (
{{ get_latest_dense_rank(
external_table = ref('stg_transit_database__services'),
order_by = 'calitp_extracted_at DESC'
) }}
),

latest_funding_programs AS (
{{ get_latest_dense_rank(
external_table = ref('stg_transit_database__funding_programs'),
order_by = 'calitp_extracted_at DESC'
) }}
),

bridge_services_x_funding_programs AS (
{{ transit_database_many_to_many(
table_a = 'latest_services',
table_a_key_col = 'key',
table_a_key_col_name = 'service_key',
table_a_name_col = 'name',
table_a_name_col_name = 'service_name',
table_a_join_col = 'funding_sources',
table_b = 'latest_funding_programs',
table_b_key_col = 'key',
table_b_key_col_name = 'funding_program_key',
table_b_name_col = 'name',
table_b_name_col_name = 'funding_program_name',
table_b_join_col = 'services'
) }}
)

SELECT * FROM bridge_services_x_funding_programs
19 changes: 19 additions & 0 deletions warehouse/models/mart/transit_database/dim_funding_programs.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{ config(materialized='table') }}

WITH latest AS (
{{ get_latest_dense_rank(
external_table = ref('stg_transit_database__funding_programs'),
order_by = 'calitp_extracted_at DESC'
) }}
),

dim_funding_programs AS (
SELECT
key,
program,
category,
calitp_extracted_at
FROM latest
)

SELECT * FROM dim_funding_programs
2 changes: 2 additions & 0 deletions warehouse/models/mart/transit_database/dim_organizations.sql
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ WITH latest AS (
order_by = 'calitp_extracted_at DESC'
) }}
),

dim_organizations AS (
SELECT
key,
Expand All @@ -15,6 +16,7 @@ dim_organizations AS (
itp_id,
details,
caltrans_district,
website,
calitp_extracted_at
FROM latest
)
Expand Down
1 change: 1 addition & 0 deletions warehouse/models/mart/transit_database/dim_services.sql
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ dim_services AS (
service_type,
mode,
currently_operating,
operating_counties,
calitp_extracted_at
FROM latest
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ stg_transit_database__organizations AS (
caltrans_district,
mobility_services_managed,
parent_organization,
website,
dt AS calitp_extracted_at
FROM latest
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ stg_transit_database__services AS (
paratransit_for,
provider,
operator,
funding_sources,
operating_counties,
dt AS calitp_extracted_at
FROM latest
)
Expand Down

0 comments on commit 53dd5ca

Please sign in to comment.