diff --git a/dbt/models/pinval/columns.md b/dbt/models/pinval/columns.md index 2b9629c9d..d464d6fd9 100644 --- a/dbt/models/pinval/columns.md +++ b/dbt/models/pinval/columns.md @@ -120,6 +120,16 @@ There are two cases in which this column might be null: {% enddocs %} +## pin_class + +{% docs column_pinval_pin_class %} +The property class for the PIN. + +Unlike `char_class`, which may vary per card, +`pin_class` always reflects the class assigned to the PIN in +`default.vw_pin_universe`. +{% enddocs %} + ## reason_report_ineligible {% docs column_pinval_reason_report_ineligible %} diff --git a/dbt/models/pinval/pinval.assessment_card.sql b/dbt/models/pinval/pinval.assessment_card.sql index 84bbf9351..8d8ad037f 100644 --- a/dbt/models/pinval/pinval.assessment_card.sql +++ b/dbt/models/pinval/pinval.assessment_card.sql @@ -236,6 +236,7 @@ SELECT COALESCE(twn.township_name, uni.township_name) AS meta_township_name, COALESCE(ac.meta_nbhd_code, uni.nbhd_code) AS meta_nbhd_code, LOWER(uni.triad_name) AS meta_triad_name, + uni.class AS pin_class, COALESCE(ac.char_class, uni.class) AS char_class, COALESCE(card_cd.class_desc, pin_cd.class_desc) AS char_class_desc, COALESCE(ac.assessment_triad, uni.assessment_triad) @@ -269,19 +270,10 @@ SELECT ac.meta_pin IS NOT NULL AND ac.meta_card_num IS NOT NULL AND LOWER(uni.triad_name) = LOWER(uni.assessment_triad) - -- Fix for one 2024 PIN that switched from regression class to - -- non-regression class between the date when we ran the final model - -- and the date we ran final comps. Without the filter below, this view - -- will consider the PIN to be eligible for a report, because it had - -- a regression class at the time of final modeling; however, the PIN - -- doesn't have any comps, because it had a non-regression class at the - -- time of comps. - -- - -- An alternative approach might be to use the presence of comps to - -- determine report eligibilty, but eligible reports without comps - -- can be a useful signal of something going wrong with our eligibility - -- criteria, so instead we hardcode this exception. - AND NOT (ac.meta_pin = '10361150280000' AND ac.assessment_year = '2024') + -- Only count as report eligible if pin has a valid regression class + AND pin_cd.class_code IS NOT NULL + AND pin_cd.regression_class + AND pin_cd.modeling_group IN ('SF', 'MF', 'BB') ) AS is_report_eligible, CASE -- In some rare cases the parcel class can be different from diff --git a/dbt/models/pinval/schema.yml b/dbt/models/pinval/schema.yml index 55a6e377b..2dfd945e4 100644 --- a/dbt/models/pinval/schema.yml +++ b/dbt/models/pinval/schema.yml @@ -113,6 +113,8 @@ models: data_tests: - not_null: name: pinval_assessment_card_meta_triad_name_not_null + - name: pin_class + description: '{{ doc("column_pinval_pin_class") }}' - name: reason_report_ineligible description: '{{ doc("column_pinval_reason_report_ineligible") }}' data_tests: @@ -127,7 +129,6 @@ models: # There are a handful of known PINs that had the wrong class # at modeling time, and so got a model value even though it # should not have - error_if: ">6" - not_accepted_values: name: pinval_assessment_card_reason_report_ineligible_not_non_tri_for_tri values: