-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
airtable: new fields & tables to address #1630
- Loading branch information
Laurie Merrell
committed
Jul 13, 2022
1 parent
dd83a0a
commit 53dd5ca
Showing
6 changed files
with
59 additions
and
0 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
warehouse/models/mart/transit_database/bridge_services_x_funding_programs.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
19
warehouse/models/mart/transit_database/dim_funding_programs.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters