Skip to content

Commit

Permalink
cdbg output sorting, missing columns (#1385)
Browse files Browse the repository at this point in the history
* order cdbg product tables

* add individual low and mod pop columns
  • Loading branch information
fvankrieken authored Jan 9, 2025
1 parent 7de3df5 commit f39ad40
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 1 deletion.
4 changes: 3 additions & 1 deletion products/cdbg/models/intermediate/_intermediate_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ models:
- name: residential_floor_area
- name: residential_floor_area_percentage
- name: potential_lowmod_population
- name: lowmod_population
- name: low_mod_income_population
- name: low_mod_income_population_percentage
- name: low_income_population
- name: mod_income_population
- name: geom
tests: [ not_null ]

Expand Down
2 changes: 2 additions & 0 deletions products/cdbg/models/intermediate/int__block_groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ block_groups_demographics AS (
block_groups_income.block_group,
block_groups_income.potential_lowmod_population,
block_groups_income.low_mod_income_population,
block_groups_income.low_income_population,
block_groups_income.mod_income_population,
block_groups_income.low_mod_income_population_percentage
FROM block_groups
LEFT JOIN block_groups_income
Expand Down
10 changes: 10 additions & 0 deletions products/cdbg/models/product/_product_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,14 @@ models:
data_type: decimal
tests: [ not_null ]

- name: low_income_population
data_type: integer
tests: [ not_null ]

- name: mod_income_population
data_type: integer
tests: [ not_null ]

- name: eligibility_flag
data_type: boolean
tests: [ not_null ]
Expand Down Expand Up @@ -205,6 +213,8 @@ models:
- name: '"Total Population"'
- name: '"Number of Low-/ Moderate-Income Persons"'
- name: '"% of Low-/ Moderate-Income Persons"'
- name: '"Low-Income"'
- name: '"Moderate-Income"'
- name: '"Eligibility"'

- name: cdbg_zap_eligibility
Expand Down
3 changes: 3 additions & 0 deletions products/cdbg/models/product/cdbg_block_groups.sql
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ renamed AS (
potential_lowmod_population::integer,
low_mod_income_population::integer,
round(low_mod_income_population_percentage::numeric, 2) AS low_mod_income_population_percentage,
low_income_population::integer,
mod_income_population::integer,
low_mod_income_population_percentage >= 51 AND residential_floor_area_percentage >= 50 AS eligibility_flag
FROM block_groups
)
Expand All @@ -27,3 +29,4 @@ SELECT
ELSE 'Ineligible'
END AS eligibility
FROM renamed
ORDER BY bctbg2020
1 change: 1 addition & 0 deletions products/cdbg/models/product/cdbg_tracts.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,4 @@ SELECT
eligibility_flag,
eligibility
FROM {{ ref("int__tracts") }}
ORDER BY bct2020
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,7 @@ SELECT
potential_lowmod_population AS "Total Population",
low_mod_income_population AS "Number of Low-/ Moderate-Income Persons",
low_mod_income_population_percentage AS "% of Low-/ Moderate-Income Persons",
low_income_population AS "Low-Income",
mod_income_population AS "Moderate-Income",
eligibility AS "Eligibility"
FROM block_groups
2 changes: 2 additions & 0 deletions products/cdbg/models/staging/stg__low_mod_by_block_group.sql
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ SELECT
"TRACT"::text AS tract,
"BLKGRP"::text AS block_group,
REPLACE("LOWMODUNIV", ',', '')::decimal AS potential_lowmod_population,
REPLACE("LOW", ',', '')::decimal AS low_income_population,
REPLACE("LOWMOD", ',', '')::decimal - REPLACE("LOW", ',', '')::decimal AS mod_income_population,
REPLACE("LOWMOD", ',', '')::decimal AS low_mod_income_population,
RTRIM("LOWMOD_PCT", '%')::numeric AS low_mod_income_population_percentage
FROM {{ source("recipe_sources", "hud_lowmodincomebyblockgroup") }}

0 comments on commit f39ad40

Please sign in to comment.