-
Notifications
You must be signed in to change notification settings - Fork 5
Move HIE counts to res model view #995
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
19eecef
b38e2a6
fe1461d
7436c94
c9740eb
833e7fc
b71e54a
b0fd91b
0c68688
9e92cfc
66c3c20
826f215
54ce456
9a42551
04e436c
f0710fa
3074744
e177f29
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -12,6 +12,58 @@ WITH multicodes AS ( | |||||||||||||||||||
| GROUP BY parid, taxyr | ||||||||||||||||||||
| ), | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- Gather HIE start and end years from both ADDN and OBY tables. We need to | ||||||||||||||||||||
| -- stack them to properly count the number of active and expiring HIEs for each | ||||||||||||||||||||
| -- PIN-year combination below. We define unique start and end dates within cards | ||||||||||||||||||||
| -- as separate HIEs. | ||||||||||||||||||||
| all_hies AS ( | ||||||||||||||||||||
| SELECT DISTINCT | ||||||||||||||||||||
| parid AS pin, | ||||||||||||||||||||
| card, | ||||||||||||||||||||
| taxyr AS year, | ||||||||||||||||||||
| CAST(taxyr AS INT) AS year_int, | ||||||||||||||||||||
| userval1 AS hie_start, | ||||||||||||||||||||
| userval2 AS hie_end | ||||||||||||||||||||
| FROM {{ source('iasworld', 'addn') }} | ||||||||||||||||||||
| WHERE lline > 0 | ||||||||||||||||||||
| AND cur = 'Y' | ||||||||||||||||||||
| AND deactivat IS NULL | ||||||||||||||||||||
| AND userval1 IS NOT NULL | ||||||||||||||||||||
| AND userval2 IS NOT NULL | ||||||||||||||||||||
| UNION ALL | ||||||||||||||||||||
| SELECT DISTINCT | ||||||||||||||||||||
| parid AS pin, | ||||||||||||||||||||
| card, | ||||||||||||||||||||
| taxyr AS year, | ||||||||||||||||||||
| CAST(taxyr AS INT) AS year_int, | ||||||||||||||||||||
| CAST(user10 AS INT) AS hie_start, | ||||||||||||||||||||
| CAST(user14 AS INT) AS hie_end | ||||||||||||||||||||
| FROM {{ source('iasworld', 'oby') }} | ||||||||||||||||||||
| WHERE cur = 'Y' | ||||||||||||||||||||
| AND deactivat IS NULL | ||||||||||||||||||||
| AND user10 IS NOT NULL | ||||||||||||||||||||
| AND user14 IS NOT NULL | ||||||||||||||||||||
| AND class = '288' | ||||||||||||||||||||
| ), | ||||||||||||||||||||
|
|
||||||||||||||||||||
| hies AS ( | ||||||||||||||||||||
| SELECT | ||||||||||||||||||||
| pin, | ||||||||||||||||||||
| year, | ||||||||||||||||||||
| SUM( | ||||||||||||||||||||
| CAST( | ||||||||||||||||||||
| -- HIE adjustments to AVs in iasworld.asmt include the start and | ||||||||||||||||||||
| -- end years, so we use a between statement here. | ||||||||||||||||||||
| year_int BETWEEN hie_start AND hie_end AS INT | ||||||||||||||||||||
| ) | ||||||||||||||||||||
| ) AS hie_num_active, | ||||||||||||||||||||
| SUM(CAST(year_int = hie_end AS INT)) AS hie_num_expiring | ||||||||||||||||||||
|
Comment on lines
+57
to
+60
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Thought, non-blocking] You may have noticed this already, but heads up that there are some obviously incorrect dates in the hie_start queryselect
hie_start,
count(*) as cnt
from (
SELECT
taxyr AS year,
CAST(userval1 AS INT) AS hie_start
FROM iasworld.addn
WHERE lline > 0
AND cur = 'Y'
AND deactivat IS NULL
AND userval1 IS NOT NULL
AND userval2 IS NOT NULL
union all
SELECT
taxyr AS year,
CAST(user10 AS INT) AS hie_start
FROM iasworld.oby
WHERE cur = 'Y'
AND deactivat IS NULL
AND user10 IS NOT NULL
AND user14 IS NOT NULL
AND class = '288'
) as all_hie
where hie_start not between 2000 and 2026
group by 1
order by 1
hie_end queryselect
hie_end,
count(*) as cnt
from (
SELECT
taxyr AS year,
CAST(userval2 AS INT) AS hie_end
FROM iasworld.addn
WHERE lline > 0
AND cur = 'Y'
AND deactivat IS NULL
AND userval1 IS NOT NULL
AND userval2 IS NOT NULL
union all
SELECT
taxyr AS year,
CAST(user14 AS INT) AS hie_end
FROM iasworld.oby
WHERE cur = 'Y'
AND deactivat IS NULL
AND user10 IS NOT NULL
AND user14 IS NOT NULL
AND class = '288'
) as all_hie
where hie_end not between 2022 and 2032
group by 1
order by 1
There are few enough of these that it feels like it might be possible to get Valuations to fix them. But I wonder if it's worth it, since there are so few? If we think it's worth it, we could pull this out into a separate view and add some data integrity tests on top of it. |
||||||||||||||||||||
| FROM all_hies | ||||||||||||||||||||
| GROUP BY | ||||||||||||||||||||
| pin, | ||||||||||||||||||||
| year | ||||||||||||||||||||
| ), | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- Conditionals in CTE do not ensure distinct outputs | ||||||||||||||||||||
| pools AS ( | ||||||||||||||||||||
| SELECT | ||||||||||||||||||||
|
|
@@ -129,7 +181,11 @@ SELECT | |||||||||||||||||||
| -- This is a brand new characteristic being collected by Valuations and we | ||||||||||||||||||||
| -- are not yet confident about its completeness or accuracy. | ||||||||||||||||||||
| -- This is not currently being used in open data or modeling. | ||||||||||||||||||||
| COALESCE(pools.in_ground_pool, FALSE) AS char_in_ground_pool | ||||||||||||||||||||
| COALESCE(pools.in_ground_pool, FALSE) AS char_in_ground_pool, | ||||||||||||||||||||
|
|
||||||||||||||||||||
| -- HIE data | ||||||||||||||||||||
| COALESCE(hies.hie_num_active, 0) AS hie_num_active, | ||||||||||||||||||||
| COALESCE(hies.hie_num_expiring, 0) AS hie_num_expiring | ||||||||||||||||||||
|
|
||||||||||||||||||||
| FROM {{ source('iasworld', 'pardat') }} AS par | ||||||||||||||||||||
| INNER JOIN {{ source('iasworld', 'dweldat') }} AS dwel | ||||||||||||||||||||
|
|
@@ -151,6 +207,9 @@ LEFT JOIN {{ source('iasworld', 'legdat') }} AS leg | |||||||||||||||||||
| LEFT JOIN pools | ||||||||||||||||||||
| ON dwel.parid = pools.parid | ||||||||||||||||||||
| AND dwel.taxyr = pools.taxyr | ||||||||||||||||||||
| LEFT JOIN hies | ||||||||||||||||||||
| ON dwel.parid = hies.pin | ||||||||||||||||||||
| AND dwel.taxyr = hies.year | ||||||||||||||||||||
| WHERE par.cur = 'Y' | ||||||||||||||||||||
| AND par.deactivat IS NULL | ||||||||||||||||||||
| AND par.class NOT IN ('999') | ||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,14 @@ Control table for `asmt` admin module - multi-jurisdiction version. | |
| Residential additions. Stores data about Home Improvement Exemptions (HIEs) | ||
| and other information about `iasworld.dweldat` properties. | ||
|
|
||
| ### Nuance | ||
|
|
||
| - In order to isolate HIEs, condition on `lline > 0` | ||
| - HIEs from `addn` can be joined to dweldat by card | ||
| - The characteristic changes in `addn` are applied immediately to the | ||
| corresponding `dweldat` characteristics rather then when HIEs "roll off". | ||
| - Individual HIEs are defined within start/end year and card | ||
|
|
||
| **Primary Key**: `jur`, `taxyr`, `parid`, `card`, `lline` | ||
| {% enddocs %} | ||
|
|
||
|
|
@@ -298,6 +306,15 @@ Taxpayer information such as name and mailing address. | |
| Outbuilding table. This is the main storage table for condo unit-level data. | ||
| It also stores other miscellaneous sub-PIN information like HIEs. | ||
|
|
||
| ### Nuance | ||
|
|
||
| - In order to isolate HIEs, condition on `class = '288'` | ||
| - HIEs from `oby` cannot necessarily be joined to `dweldat` by card, though that | ||
| is the intended behavior | ||
| - The characteristic changes in `oby` are applied immediately to the | ||
| corresponding `dweldat` characteristics rather then when HIEs "roll off". | ||
|
Comment on lines
+311
to
+315
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Mirella confirmed this is the case for |
||
| - Individual HIEs are defined within start/end year and card | ||
|
|
||
| **Primary Key**: `jur`, `taxyr`, `parid`, `card`, `lline` | ||
| {% enddocs %} | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,6 +114,8 @@ forward_fill AS ( | |
| ch.char_ncu, | ||
| ch.char_tp_plan, | ||
| ch.char_recent_renovation, | ||
| ch.hie_num_active, | ||
| ch.hie_num_expiring, | ||
|
|
||
| -- Land and lot size indicators | ||
| sp.char_land_sf_95_percentile, | ||
|
|
@@ -216,6 +218,8 @@ SELECT | |
| f1.char_ncu, | ||
| f1.char_tp_plan, | ||
| f1.char_recent_renovation, | ||
| f1.hie_num_active, | ||
| f1.hie_num_expiring, | ||
|
Comment on lines
+221
to
+222
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [Question, non-blocking] Somehow we're ending up with nulls here. Is that a problem? select count(*)
from z_ci_add_hies_to_shared_model_view_model.vw_card_res_input
where hie_num_active is null or hie_num_expiring is null
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I noticed this too. There are no nulls in |
||
| f1.char_land_sf_95_percentile, | ||
| f1.ind_land_gte_95_percentile, | ||
| f1.char_bldg_sf_95_percentile, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1113,6 +1113,18 @@ Possible values for this variable are: | |
| Year the property was constructed | ||
| {% enddocs %} | ||
|
|
||
| ## hie_num_active | ||
|
|
||
| {% docs shared_column_hie_num_active %} | ||
| Number of active home improvement exemptions | ||
| {% enddocs %} | ||
|
|
||
| ## hie_num_expiring | ||
|
|
||
| {% docs shared_column_hie_num_expiring %} | ||
| Number of home improvement exemptions that will expire after the current year | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I realize "after the current year" is a little wonky, but it seems like the most straightforward way to build this given the inclusive nature of the start/end years. |
||
| {% enddocs %} | ||
|
|
||
| # Cook County | ||
|
|
||
| ## card | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can use
mailed_hiefromdefault.vw_pin_valueto confirm these start/end dates are inclusive: