-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create new NTD mart table dim_annual_ntd_funding_source containing al…
…l records from federal, state, and local funding source tables. [#3405]
- Loading branch information
Showing
2 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
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
115 changes: 115 additions & 0 deletions
115
warehouse/models/mart/ntd/dim_annual_ntd_funding_source.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,115 @@ | ||
{{ config(materialized='table') }} | ||
|
||
WITH local_funding_sources AS ( | ||
SELECT "local" AS funding_source_type, | ||
agency, | ||
agency_voms, | ||
city, | ||
fuel_tax, | ||
null AS fta_capital_program_5309, | ||
null AS fta_rural_progam_5311, | ||
null AS fta_urbanized_area_formula, | ||
general_fund, | ||
null AS general_funds, | ||
income_tax, | ||
ntd_id, | ||
organization_type, | ||
null AS other_dot_funds, | ||
null AS other_federal_funds, | ||
null AS other_fta_funds, | ||
other_funds, | ||
other_taxes, | ||
primary_uza_population, | ||
property_tax, | ||
reduced_reporter_funds, | ||
report_year, | ||
reporter_type, | ||
sales_tax, | ||
state, | ||
tolls, | ||
total, | ||
null AS total_federal_funds, | ||
'' AS total_questionable, | ||
null AS transportation_funds, | ||
uace_code, | ||
uza_name | ||
FROM {{ ref("stg_ntd_annual_data__2022__funding_sources_local") }} | ||
), | ||
|
||
state_funding_sources AS ( | ||
SELECT "state" AS funding_source_type, | ||
agency, | ||
agency_voms, | ||
city, | ||
null AS fuel_tax, | ||
null AS fta_capital_program_5309, | ||
null AS fta_rural_progam_5311, | ||
null AS fta_urbanized_area_formula, | ||
null AS general_fund, | ||
general_funds, | ||
null AS income_tax, | ||
ntd_id, | ||
organization_type, | ||
null AS other_dot_funds, | ||
null AS other_federal_funds, | ||
null AS other_fta_funds, | ||
null AS other_funds, | ||
null AS other_taxes, | ||
primary_uza_population, | ||
null AS property_tax, | ||
reduced_reporter_funds, | ||
report_year, | ||
reporter_type, | ||
null AS sales_tax, | ||
state, | ||
null AS tolls, | ||
total, | ||
null AS total_federal_funds, | ||
total_questionable, | ||
transportation_funds, | ||
uace_code, | ||
uza_name | ||
FROM {{ ref("stg_ntd_annual_data__2022__funding_sources_state") }} | ||
), | ||
|
||
federal_funding_sources AS ( | ||
SELECT "federal" AS funding_source_type, | ||
agency, | ||
agency_voms, | ||
city, | ||
null AS fuel_tax, | ||
fta_capital_program_5309, | ||
fta_rural_progam_5311, | ||
fta_urbanized_area_formula, | ||
null AS general_fund, | ||
null AS general_funds, | ||
null AS income_tax, | ||
ntd_id, | ||
organization_type, | ||
other_dot_funds, | ||
other_federal_funds, | ||
other_fta_funds, | ||
null AS other_funds, | ||
null AS other_taxes, | ||
primary_uza_population, | ||
null AS property_tax, | ||
null AS reduced_reporter_funds, | ||
report_year, | ||
reporter_type, | ||
null AS sales_tax, | ||
state, | ||
null AS tolls, | ||
null AS total, | ||
total_federal_funds, | ||
'' AS total_questionable, | ||
null AS transportation_funds, | ||
uace_code, | ||
uza_name | ||
FROM {{ ref("stg_ntd_annual_data__2022__funding_sources_federal") }} | ||
) | ||
|
||
SELECT * FROM local_funding_sources | ||
UNION ALL | ||
SELECT * FROM state_funding_sources | ||
UNION ALL | ||
SELECT * FROM federal_funding_sources |