Skip to content

Simplify the pinval.vw_assessment_card data model#856

Merged
jeancochrane merged 9 commits intomasterfrom
jeancochrane/855-avoid-selecting-star-from-modelassessment_card-in-pinvalvw_assessment_card
Jul 11, 2025
Merged

Simplify the pinval.vw_assessment_card data model#856
jeancochrane merged 9 commits intomasterfrom
jeancochrane/855-avoid-selecting-star-from-modelassessment_card-in-pinvalvw_assessment_card

Conversation

@jeancochrane
Copy link
Member

@jeancochrane jeancochrane commented Jul 10, 2025

This PR follows up on the changes we made to pinval.vw_assessment_card in #851 to add rows for every parcel in the County for every model run. That PR used a confusing convention of parcel_* and model_* column name prefixes for new columns in order to skirt around the problem that we select * from model.assessment_card and so can't rename any of its columns. This PR resolves this problem at the root by instead selecting the specific columns that we want from model.assessment_card such that we can filter them, rename them, or transform them.

Note that this choice introduces a maintenance burden, in that we have to manually add any new predictors to the set of selected columns in pinval.vw_assessment_card whenever we add new predictors to the res model. We make two changes to mitigate the risk that we will forget to do this:

  1. The addition of a new data integrity test in this PR to ensure that every model_predictor_all_name array in this table is a subset of the columns of the pinval.vw_assessment_card table
  2. A corresponding PR in model-res-avm to update the annual model finalization checklist to include an item for updating pinval.vw_assessment_card to include any new predictors (Add item to annual model issue checklist for double-checking pinval resources model-res-avm#384)

This PR also folds in one small unrelated data model change to pinval.vw_comp, switching from the temporary model.pinval_test_training_data table to the permanent model.training_data table that we added in #804 in order to augment comps with training data characteristics. That change resolves #803.

Connects #855.

Companion PRs:

## meta_card_num

{% docs meta_card_num %}
{% docs column_pinval_meta_card_num %}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure how I didn't catch this in #851, but this docs block identifier should follow our standard {type}_{schema}_* naming pattern.


{% enddocs %}

## model_run_id
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These docs blocks are not being deleted, but have rather been renamed and moved to other parts of the file in order to follow our block sorting rules.

Comment on lines +92 to +94
-- Join on year rather than run ID because `model.training_data` is
-- guaranteed to be unique by year but may have a different run ID
-- than the comps run
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a little bit confusing, and notably it means that pinval.vw_comp will have a run ID that matches pinval.vw_assessment_card for now (2025-02-11-charming-eric), since model.training_data and pinval.vw_assessment_card both use the final 2025 model. There's probably a better way to solve this, but one of my tasks for the month is to figure out a permanent solution to the final/comp model run discrepancy issue, so I think an imperfect solution is fine for now.

@jeancochrane jeancochrane marked this pull request as ready for review July 10, 2025 22:11
@jeancochrane jeancochrane requested a review from a team as a code owner July 10, 2025 22:11
Copy link
Member

@wagnerlmichael wagnerlmichael left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, just a question to confirm my understanding of one of the data tests.

-- included in the assessment set for a given model run. We need these
-- essential attrs even when parcels aren't in the assessment set in order
-- to generate detailed descriptions for why those parcels don't have
-- reports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Praise]: Very clear docs

AND table_name = '{{ ref("pinval.vw_assessment_card").identifier }}'
)
)
) = 0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Question]: So the ARRAY_EXCEPT acts as a set difference, and then CARDINALITY checks to see if there is anything returned from that set difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, you've got it! I clarified the comment in 5952ee7 to make this explicit.

@jeancochrane jeancochrane merged commit 0d5c2d2 into master Jul 11, 2025
8 checks passed
@jeancochrane jeancochrane deleted the jeancochrane/855-avoid-selecting-star-from-modelassessment_card-in-pinvalvw_assessment_card branch July 11, 2025 21:14
jeancochrane added a commit to ccao-data/homeval that referenced this pull request Jul 11, 2025
…#85)

This PR updates our Hugo report generation code to handle the changes to
the `pinval.vw_assessment_card` data model that we're making in
ccao-data/data-architecture#856.

In addition, we fold in one small change to improve the experience of
testing changes to the data model: Factoring out constants for
`PINVAL_ASSESSMENT_CARD_TABLE` and `PINVAL_COMP_TABLE`. By centralizing
the references to these two tables, we can more easily change them when
we need to test a corresponding change in `data-architecture`.

See PIN `06171140020000` on the staging site for an example of a
deployed report.

Connects ccao-data/data-architecture#855.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Avoid selecting star from model.assessment_card in pinval.vw_assessment_card Switch PINVAL tables to use model.training_data

2 participants