Skip to content

Commit

Permalink
Adjust mktadj tests to reflect the switch to external_occpctand n…
Browse files Browse the repository at this point in the history
…ew `5B` code (#404)

* Adjust dweldat tests that reference mktadj to also reference external_occpct

* Adjust comdat and oby tests for chgrsn/mktadj to reference external_occpct

* Fix typos in dweldat mktrsn tests
  • Loading branch information
jeancochrane authored Apr 23, 2024
1 parent 3dba9ff commit 66442f5
Show file tree
Hide file tree
Showing 4 changed files with 186 additions and 25 deletions.
12 changes: 8 additions & 4 deletions dbt/models/iasworld/columns.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,8 +225,11 @@ Condition/Desirability/Utility code
{% docs column_chgrsn %}
Reason code for change of value.

`4` = Regular reduction (lasts until next triennial reassessment)
`5` = One year only market value relief (occupancy/vacancy reduction)
Possible values for this variable are:

- `4` = Regular reduction (lasts until next triennial reassessment)
- `5` = One year only market value relief (occupancy/vacancy reduction)
- `5B` = One year only market value relief, issued by the Board of Review
{% enddocs %}

## cityname
Expand Down Expand Up @@ -460,10 +463,11 @@ Marital status
## mktadj

{% docs column_mktadj %}
Percent good override.
Percent good override, deprecated in 2024.

Typically used to denote a 1-year percentage discount due to vacancy
or similar temporary situations.
or similar temporary situations. For 2023 data, check `external_occpct`
as well. For 2024 on, use `external_occpct` instead.
{% enddocs %}

## nccalc
Expand Down
68 changes: 61 additions & 7 deletions dbt/models/iasworld/schema/iasworld.comdat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,21 +101,30 @@ sources:
- name: chgrsn
description: '{{ doc("column_chgrsn") }}'
tests:
- expression_is_true:
name: iasworld_comdat_chgrsn_eq_5_mktadj_not_null
expression: |
!= '5' OR mktadj IS NOT NULL
- accepted_values:
name: iasworld_comdat_chgrsn_eq_5_or_5b_when_external_occpct_or_mktadj_not_null
values:
- '5'
- 5B
additional_select_columns:
- parid
- taxyr
- card
- who
- wen
- external_occpct
- mktadj
config: *unique-conditions
config:
where: |
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND (external_occpct IS NOT NULL OR mktadj IS NOT NULL)
meta:
category: incorrect_values
description: chgrsn should only be 5 if mktadj is not null
description: >
chgrsn (Reason for Change) should be 5 or 5B
if external_occpct (Occupancy % [current]) or
mktadj (Occupancy % [deprecated]) is not null
- name: class
description: '{{ doc("shared_column_class") }}'
tests:
Expand Down Expand Up @@ -217,6 +226,28 @@ sources:
meta:
description: >
external_occpct (Occupancy %) should not be 0
- not_null:
name: iasworld_comdat_external_occpct_not_null_when_chgrsn_eq_5_or_5b_and_mktadj_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- chgrsn
- mktadj
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND chgrsn IN ('5', '5B')
AND mktadj IS NULL
meta:
description: >
external_occpct (Occupancy % [current]) should not be null if
chgrsn (Reason for Change) is 5 or 5B and
mktadj (Occupancy % [deprecated]) is null
- name: external_propct
description: '{{ doc("shared_column_external_propct") }}'
tests:
Expand Down Expand Up @@ -257,6 +288,29 @@ sources:
description: '{{ doc("shared_column_loaded_at") }}'
- name: mktadj
description: '{{ doc("column_mktadj") }}'
tests:
- not_null:
name: iasworld_comdat_mktadj_not_null_when_chgrsn_eq_5_or_5b_and_external_occpct_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- chgrsn
- external_occpct
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND chgrsn IN ('5', '5B')
AND external_occpct IS NULL
meta:
description: >
mktadj (Occupancy % [deprecated]) should not be null if
chgrsn (Reason for Change) is 5 or 5B and
external_occpct (Occupancy % [current]) is null
- name: mktrsn
description: Reason for market adjustment
- name: msarea
Expand Down
61 changes: 55 additions & 6 deletions dbt/models/iasworld/schema/iasworld.dweldat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,28 @@ sources:
meta:
description: >
external_occpct (Occupancy %) should not be 0
- not_null:
name: iasworld_dweldat_external_occpct_not_null_when_mktrsn_eq_5_or_5b_and_mktadj_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- mktrsn
- mktadj
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND mktrsn IN ('5', '5B')
AND mktadj IS NULL
meta:
description: >
external_occpct (Occupancy % [current]) should not be null if
mktrsn (Reason for Override) is 5 or 5B and
mktadj (Occupancy % [deprecated]) is null
- name: external_propct
description: '{{ doc("shared_column_external_propct") }}'
tests:
Expand Down Expand Up @@ -581,29 +603,56 @@ sources:
description: Main section ground floor area
- name: mktadj
description: '{{ doc("column_mktadj") }}'
tests:
- not_null:
name: iasworld_dweldat_mktadj_not_null_when_mktrsn_eq_5_or_5b_and_external_occpct_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- mktrsn
- external_occpct
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND mktrsn IN ('5', '5B')
AND external_occpct IS NULL
meta:
description: >
mktadj (Occupancy % [deprecated]) should not be null if
mktrsn (Reason for Override) is 5 or 5B and
external_occpct (Occupancy % [current]) is null
- name: mktrsn
description: '{{ doc("column_chgrsn") }}'
tests:
- expression_is_true:
name: iasworld_dweldat_mktrsn_eq_5_mktadj_not_null
expression: |
!= '5' OR mktadj IS NOT NULL
- accepted_values:
name: iasworld_dweldat_mktrsn_eq_5_or_5b_when_external_occpct_or_mktadj_not_null
values:
- '5'
- 5B
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- external_occpct
- mktadj
config:
where: |
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND (external_occpct IS NOT NULL OR mktadj IS NOT NULL)
meta:
category: incorrect_values
description: >
mktrsn (Reason for Override) should only be 5 if mktadj is not null
mktrsn (Reason for Override) should be 5 or 5B
if external_occpct (Occupancy % [current]) or
mktadj (Occupancy % [deprecated]) is not null
- name: modover
description: Residential override model
- name: mvpattic
Expand Down
70 changes: 62 additions & 8 deletions dbt/models/iasworld/schema/iasworld.oby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,21 +80,30 @@ sources:
- name: chgrsn
description: '{{ doc("column_chgrsn") }}'
tests:
- expression_is_true:
name: iasworld_oby_chgrsn_eq_5_mktadj_not_null
expression: |
!= '5' OR mktadj IS NOT NULL
- accepted_values:
name: iasworld_oby_chgrsn_eq_5_or_5b_when_external_occpct_or_mktadj_not_null
values:
- '5'
- 5B
additional_select_columns:
- taxyr
- parid
- taxyr
- card
- who
- wen
- external_occpct
- mktadj
config: *unique-conditions
config:
where: |
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND (external_occpct IS NOT NULL OR mktadj IS NOT NULL)
meta:
category: incorrect_values
description: chgrsn should only be 5 if mktadj is not null
description: >
chgrsn (Reason for Change) should be 5 or 5B
if external_occpct (Occupancy % [current]) or
mktadj (Occupancy % [deprecated]) is not null
- name: class
description: '{{ doc("shared_column_class") }}'
tests:
Expand Down Expand Up @@ -212,6 +221,28 @@ sources:
meta:
description: >
external_occpct (Occupancy %) should not be 0
- not_null:
name: iasworld_oby_external_occpct_not_null_when_chgrsn_eq_5_or_5b_and_mktadj_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- chgrsn
- mktadj
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND chgrsn IN ('5', '5B')
AND mktadj IS NULL
meta:
description: >
external_occpct (Occupancy % [current]) should not be null if
chgrsn (Reason for Change) is 5 or 5B and
mktadj (Occupancy % [deprecated]) is null
- name: external_propct
description: '{{ doc("shared_column_external_propct") }}'
tests:
Expand Down Expand Up @@ -289,6 +320,29 @@ sources:
description: Miles for railroads
- name: mktadj
description: '{{ doc("column_mktadj") }}'
tests:
- not_null:
name: iasworld_oby_mktadj_not_null_when_chgrsn_eq_5_or_5b_and_external_occpct_is_null
additional_select_columns:
- taxyr
- parid
- card
- who
- wen
- chgrsn
- external_occpct
config:
where:
CAST(taxyr AS int) BETWEEN {{ var('test_qc_year_start') }} AND {{ var('test_qc_year_end') }}
AND cur = 'Y'
AND deactivat IS NULL
AND chgrsn IN ('5', '5B')
AND external_occpct IS NULL
meta:
description: >
mktadj (Occupancy % [deprecated]) should not be null if
chgrsn (Reason for Change) is 5 or 5B and
external_occpct (Occupancy % [current]) is null
- name: msclass
description: Class identifier for Occupancy (CODE) from Marshall Swift
- name: msrank
Expand Down

0 comments on commit 66442f5

Please sign in to comment.