Skip to content
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

Add iasWorld dbt tests and namespace all tests #236

Merged
merged 32 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aa1ad67
Initial sale view tests
dfsnow Nov 15, 2023
4d3c6ed
Add ADDN tests
dfsnow Nov 15, 2023
cdf2761
Add ADPRVAL tests
dfsnow Nov 16, 2023
9f8eedc
Add ASMT_ALL tests
dfsnow Nov 16, 2023
047483e
Revert "Initial sale view tests"
dfsnow Nov 17, 2023
47dfea3
Add new test macro for mismatched rows
dfsnow Nov 17, 2023
2f93f33
Test mismatched classes in ASMT_ALL vs PARDAT
dfsnow Nov 17, 2023
a6d5a18
Update class comparison tests
dfsnow Nov 17, 2023
c7fb3c8
Improve class match testing
dfsnow Nov 17, 2023
9bcdb38
Add more tests and rename all iasworld tests
dfsnow Nov 17, 2023
4b6f096
Update test names and formatting
dfsnow Nov 17, 2023
ecf8bb5
Add more DWELDAT char tests
dfsnow Nov 17, 2023
10da78c
Finish DWELDAT tests
dfsnow Nov 17, 2023
6d0145d
Add HTPAR tests
dfsnow Nov 17, 2023
2d6d42f
Add LAND table tests
dfsnow Nov 20, 2023
4df8b13
Add LEGDAT and address tests
dfsnow Nov 20, 2023
5603526
Add more LEGDAT address checks
dfsnow Nov 20, 2023
b46b353
Add OWNDAT tests
dfsnow Nov 20, 2023
0b4daec
Add PARDAT tests
dfsnow Nov 20, 2023
5f23d8f
Add OBY tests
dfsnow Nov 20, 2023
2b4bf56
Add SALES tests
dfsnow Nov 20, 2023
4d1ff64
Add tags for FP QC
dfsnow Nov 20, 2023
f55f513
Update test schemas
dfsnow Nov 20, 2023
8d6486f
Truncate test name
dfsnow Nov 20, 2023
99c2ec2
Truncate test name
dfsnow Nov 20, 2023
c3ca076
Update test name
dfsnow Nov 20, 2023
3e2af4d
Replace redundant conditions with YAML anchors
dfsnow Nov 20, 2023
2e48f66
Fix missing test namespace
dfsnow Nov 21, 2023
70b5902
Drop extra linebreaks
dfsnow Nov 21, 2023
c634f35
Add test_qc tag to all iasWorld tables
dfsnow Nov 21, 2023
040b6bb
Exclude test_qc tests from build_and_test_dbt workflow
dfsnow Nov 21, 2023
2ec996a
Add note about trigger to test_dbt_models
dfsnow Nov 21, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dbt/models/default/schema/default.vw_card_res_char.yml
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ models:

tests:
- unique_combination_of_columns:
name: vw_card_res_char_unique_by_pin_card_and_year
Copy link
Member Author

Choose a reason for hiding this comment

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

All changes in default/ are related to namespace changes. See PR body for more details.

name: default_vw_card_res_char_unique_by_pin_card_and_year
combination_of_columns:
- pin
- year
Expand Down
4 changes: 2 additions & 2 deletions dbt/models/default/schema/default.vw_pin_address.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ models:
tests:
# No superfluous whitespace
- no_extra_whitespace:
name: vw_pin_address_no_extra_whitespace
name: default_vw_pin_address_no_extra_whitespace
column_names:
- prop_address_full
- prop_address_city_name
Expand All @@ -66,7 +66,7 @@ models:
config:
error_if: ">900000"
- unique_combination_of_columns:
name: vw_pin_address_unique_by_14_digit_pin_and_year
name: default_vw_pin_address_unique_by_14_digit_pin_and_year
combination_of_columns:
- pin
- year
Expand Down
4 changes: 2 additions & 2 deletions dbt/models/default/schema/default.vw_pin_appeal.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ models:
tests:
# If there is a `change`, the values should reflect this
- expression_is_true:
name: vw_pin_appeal_change_matches_appeal_outcome
name: default_vw_pin_appeal_change_matches_appeal_outcome
expression: >-
{% set vars = [
('mailed_bldg', 'certified_bldg'),
Expand Down Expand Up @@ -94,7 +94,7 @@ models:
error_if: ">266719"
# `change` should be an enum
- expression_is_true:
name: vw_pin_appeal_no_unexpected_change_values
name: default_vw_pin_appeal_no_unexpected_change_values
expression: change is null or change in ('change', 'no change')
select_columns:
- pin
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/default/schema/default.vw_pin_condo_char.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ models:

tests:
- unique_combination_of_columns:
name: vw_pin_condo_char_unique_by_14_digit_pin_and_year
name: default_vw_pin_condo_char_unique_by_14_digit_pin_and_year
combination_of_columns:
- pin
- year
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/default/schema/default.vw_pin_history.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ models:

tests:
- unique_combination_of_columns:
name: vw_pin_history_unique_by_14_digit_pin_and_year
name: default_vw_pin_history_unique_by_14_digit_pin_and_year
combination_of_columns:
- pin
- year
4 changes: 2 additions & 2 deletions dbt/models/default/schema/default.vw_pin_sale.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ models:
tests:
# Number of sales for a given time period isn't suspicious
- unique_combination_of_columns:
name: vw_pin_sale_reasonable_number_of_sales_per_year
name: default_vw_pin_sale_reasonable_number_of_sales_per_year
combination_of_columns:
- pin
- year
Expand All @@ -66,7 +66,7 @@ models:
error_if: ">4032"
# No sales for same price/pin within 12 months
- unique_combination_of_columns:
name: vw_pin_sale_unique_price_pin_and_year
name: default_vw_pin_sale_unique_price_pin_and_year
combination_of_columns:
- pin
- year
Expand Down
6 changes: 3 additions & 3 deletions dbt/models/default/schema/default.vw_pin_universe.yml
Original file line number Diff line number Diff line change
Expand Up @@ -233,18 +233,18 @@ models:
tests:
# Number of classes is consistent over time
- count_is_consistent:
name: vw_pin_universe_class_count_is_consistent_by_year
name: default_vw_pin_universe_class_count_is_consistent_by_year
group_column: year
count_column: class
config:
error_if: ">24"
# Number of towns is consistent over time
- count_is_consistent:
name: vw_pin_universe_township_code_count_is_consistent_by_year
name: default_vw_pin_universe_town_count_is_consistent_by_year
group_column: year
count_column: township_code
- unique_combination_of_columns:
name: vw_pin_universe_unique_by_14_digit_pin_and_year
name: default_vw_pin_universe_unique_by_14_digit_pin_and_year
combination_of_columns:
- pin
- year
Expand Down
2 changes: 1 addition & 1 deletion dbt/models/default/schema/default.vw_pin_value.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ models:

tests:
- unique_combination_of_columns:
name: vw_pin_value_unique_by_14_digit_pin_and_year
name: default_vw_pin_value_unique_by_14_digit_pin_and_year
combination_of_columns:
- pin
- year
5 changes: 5 additions & 0 deletions dbt/models/iasworld/docs.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ Main assessment table, union of `iasworld.asmt` and `iasworld.asmt_hist`.
Provides the latest assessed value for each PIN and used heavily in
Data Department views.

### Nuance

- Unlike most `iasworld` tables, this table _does not_ use `cur = 'Y'` to
identify the most recent record (it uses `procname` instead).

**Primary Key**: `jur`, `rolltype`, `valclass`, `valyear`, `distcode`,
`seq` `taxyr`, `parid`, `card`
{% enddocs %}
Expand Down
59 changes: 58 additions & 1 deletion dbt/models/iasworld/schema/iasworld.addn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ sources:
columns:
- name: area
description: '{{ doc("column_area") }}'
tests:
- dbt_utils.accepted_range:
name: iasworld_addn_area_between_0_and_1.5M
min_value: 0
max_value: 1500000
config:
where: cur = 'Y' AND deactivat IS NULL
- name: area_sqm
description: Area of this line in meters
- name: areaid
Expand All @@ -20,20 +27,48 @@ sources:
description: '{{ doc("column_areasum") }}'
- name: card
description: '{{ doc("column_card") }}'
tests:
- not_null:
name: iasworld_addn_card_not_null
- dbt_utils.accepted_range:
name: iasworld_addn_card_gte_1
min_value: 1
- name: cdu
description: '{{ doc("column_cdu") }}'
- name: chgrsn
description: '{{ doc("column_chgrsn") }}'
- name: class
description: '{{ doc("shared_column_class") }}'
tests:
- relationships:
name: iasworld_addn_class_in_ccao_class_dict
to: source('ccao', 'class_dict')
field: class_code
config:
where: |
taxyr >= '2022'
AND class != 'EX'
AND cur = 'Y'
AND deactivat IS NULL
Comment on lines +43 to +53
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 test is on basically every class column in iasWorld now and is designed to catch issues like people adding a dash to classes, e.g. 2-12.

- name: convaddn
description: Converted addition total
- name: cur
description: '{{ doc("column_cur") }}'
tests:
- accepted_values:
name: iasworld_addn_cur_in_accepted_values
values: ['Y', 'D']
- name: deactivat
description: '{{ doc("column_deactivat") }}'
- name: depr
description: Percent good from tables (based on age+cdu)
tests:
- dbt_utils.accepted_range:
name: iasworld_addn_depr_between_0_and_100
min_value: 0
max_value: 100
config:
where: cur = 'Y' AND deactivat IS NULL
- name: eff_area
description: Support value per line
- name: effageovr
Expand Down Expand Up @@ -64,6 +99,9 @@ sources:
description: '{{ doc("column_jur") }}'
- name: lline
description: '{{ doc("shared_column_lline") }}'
tests:
- not_null:
name: iasworld_addn_lline_not_null
- name: lower
description: Lower level addition code
- name: mktadj
Expand All @@ -82,6 +120,13 @@ sources:
description: '{{ doc("column_newconpct") }}'
- name: parid
description: '{{ doc("shared_column_pin") }}'
tests:
- not_null:
name: iasworld_addn_parid_not_null
- relationships:
name: iasworld_addn_parid_in_pardat_parid
to: source('iasworld', 'pardat')
field: parid
- name: pctcomp
description: '{{ doc("column_pctcomp") }}'
- name: prodamage
Expand Down Expand Up @@ -126,10 +171,21 @@ sources:
description: Second floor addition code
- name: seq
description: '{{ doc("shared_column_seq") }}'
tests:
- dbt_utils.sequential_values:
name: iasworld_addn_seq_all_sequential_exist
group_by_columns:
- parid
- taxyr
- card
- lline
- name: status
description: '{{ doc("column_status") }}'
- name: taxyr
description: '{{ doc("shared_column_year") }}'
tests:
- not_null:
name: iasworld_addn_taxyr_not_null
- name: third
description: Third floor addition code
- name: trans_id
Expand All @@ -152,9 +208,10 @@ sources:
description: '{{ doc("column_whocalc") }}'
- name: yrblt
description: '{{ doc("column_yrblt") }}'

tests:
- unique_combination_of_columns:
name: addn_unique_by_parid_taxyr_card_lline
name: iasworld_addn_unique_by_parid_taxyr_card_lline
combination_of_columns:
- parid
- taxyr
Expand Down
57 changes: 56 additions & 1 deletion dbt/models/iasworld/schema/iasworld.aprval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,35 @@ sources:
description: Applied market value
- name: aprbldg
description: Appraised building value
tests:
- dbt_utils.accepted_range:
name: iasworld_aprval_aprbldg_between_0_and_1B
min_value: 0
max_value: 1000000000
config:
where: |
taxyr >= '2021'
AND cur = 'Y'
AND deactivat IS NULL
- name: aprdate
description: '`APRTOT` calc date'
- name: aprland
description: Appraised land value
tests:
- dbt_utils.accepted_range:
name: iasworld_aprval_aprland_between_0_and_1B
min_value: 0
max_value: 1000000000
config: &unique-conditions
where: cur = 'Y' AND deactivat IS NULL
Comment on lines +40 to +41
Copy link
Member Author

Choose a reason for hiding this comment

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

Since many tests require the same conditionals, I used YAML anchors a lot to repeat the same conditions across tests in the same schema file.

- name: aprtot
description: '{{ doc("column_aprtot") }}'
tests:
- dbt_utils.accepted_range:
name: iasworld_aprval_aprtot_between_0_and_2B
min_value: 0
max_value: 2000000000
config: *unique-conditions
- name: areasum
description: '{{ doc("column_areasum") }}'
- name: assmkt
Expand All @@ -31,6 +54,12 @@ sources:
description: Appraisal unit number
- name: bldgval
description: Building value
tests:
- dbt_utils.accepted_range:
name: iasworld_aprval_bldgval_between_0_and_1B
min_value: 0
max_value: 1000000000
config: *unique-conditions
- name: comincval
description: Commercial income value
- name: commktsf
Expand Down Expand Up @@ -65,6 +94,10 @@ sources:
description: Total cost value
- name: cur
description: '{{ doc("column_cur") }}'
tests:
- accepted_values:
name: iasworld_aprval_cur_in_accepted_values
values: ['Y', 'D']
- name: deactivat
description: '{{ doc("column_deactivat") }}'
- name: dwelval
Expand Down Expand Up @@ -107,6 +140,12 @@ sources:
description: Land allocation percent
- name: landval
description: Total land cost value
tests:
- dbt_utils.accepted_range:
name: iasworld_aprval_landval_between_0_and_1B
min_value: 0
max_value: 1000000000
config: *unique-conditions
- name: lastupd
description: Date of last change to a value field
- name: mandate
Expand Down Expand Up @@ -135,6 +174,13 @@ sources:
description: '{{ doc("column_ovrmraval") }}'
- name: parid
description: '{{ doc("shared_column_pin") }}'
tests:
- not_null:
name: iasworld_aprval_parid_not_null
- relationships:
name: iasworld_aprval_parid_in_pardat_parid
to: source('iasworld', 'pardat')
field: parid
- name: posttype
description: Assessment posting type
- name: ppcomval
Expand Down Expand Up @@ -177,6 +223,12 @@ sources:
description: Selected sale price
- name: seq
description: '{{ doc("shared_column_seq") }}'
tests:
- dbt_utils.sequential_values:
name: iasworld_aprval_seq_all_sequential_exist
group_by_columns:
- parid
- taxyr
- name: spcflg
description: Special processing flag
- name: splitno
Expand All @@ -189,6 +241,9 @@ sources:
description: '{{ doc("column_status") }}'
- name: taxyr
description: '{{ doc("shared_column_year") }}'
tests:
- not_null:
name: iasworld_aprval_taxyr_not_null
- name: tiebackbldg
description: Sum of building value for all children in the income tieback group
- name: tiebackland
Expand All @@ -214,7 +269,7 @@ sources:

tests:
- unique_combination_of_columns:
name: aprval_unique_by_parid_taxyr
name: iasworld_aprval_unique_by_parid_taxyr
combination_of_columns:
- parid
- taxyr
Loading
Loading