ccao-data / data-architecture

Codebase for CCAO data infrastructure construction and management
https://ccao-data.github.io/data-architecture/
5 stars 3 forks source link

Identify AHSAP properties and update reporting views #457

Closed wrridgeway closed 1 month ago

wrridgeway commented 1 month ago

This PR adds one new column to reportingvw_pin_township_class, an AHSAP indicator based on values from a number of different iasWorld fields:

land: infl1 IN (30, 31, 32) OR SUBSTR(user7, 1, 3) = 'SAP' infl1 is any of the codes 30, 31, 32, or user7 (incentive number) starts with 'SAP'

oby: SUBSTR(user16, 1, 2) = 'AI' OR SUBSTR(user3, 1, 3) = 'SAP' user16 (alt CDU) starts with 'AI' or user3 (incentive number) starts with 'SAP'

comdat: SUBSTR(user16, 1, 2) = 'AI' OR SUBSTR(user4, 1, 3) = 'SAP' OR user13 IN (49, 50, 51) user16 (alt CDU) starts with 'AI' or user4 (incentive number) starts with 'SAP' or user13 (subclass 2) is any of the codes 49, 50, 51

aprval: ecf IS NOT NULL ecf has any value in it

dweldat: SUBSTR(user16, 1, 2) = 'AI' user16 (alt CDU) starts with 'AI'

wrridgeway commented 1 month ago

This query should return nothing if our additions didn't change the view:

WITH old AS (

    SELECT
        *
    FROM reporting.vw_pin_township_class
),

new AS (

    SELECT
        pin,
        year,
        triad_name,
        triad_code,
        township_name,
        township_code,
        nbhd,
        municipality_name,
        class,
        major_class,
        property_group,
        reassessment_year
    FROM "z_ci_424_identify_ahsap_properties_and_update_reporting_views_reporting".vw_pin_township_class
)

SELECT * FROM old
EXCEPT
SELECT * FROM new

And that's what it does.

wrridgeway commented 1 month ago

The only thing to test here other than that the changes didn't alter the structure of vw_pin_township_class is the ahsap column. There really isn't a great way to do that other than to compare against the list of AHSAP parcels on the intranet. I did that and while there's a decent amount of overlap, there are differences. I sent PINs from the intranet not captured by this iasWorld logic to Brian so he can investigate. For now, this is as good as our indicator is going to get and we can update it once Brian gets back to us with any new information.