Skip to content

Commit

Permalink
add test to ensure all of lots area assigned
Browse files Browse the repository at this point in the history
  • Loading branch information
fvankrieken committed Dec 31, 2024
1 parent 7d3b0bc commit 5514820
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 9 additions & 0 deletions products/cdbg/macros/test_sum.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% test sum_by(model, group_by, target_column, val, precision=4) %}

SELECT
{{ group_by }}, sum({{ target_column }}) AS sum, array_agg( {{target_column }}) AS vals
FROM {{ model }}
GROUP BY {{ group_by }}
HAVING round(sum({{ target_column }})::numeric, {{ precision }}) <> {{ val }}

{% endtest %}
8 changes: 7 additions & 1 deletion products/cdbg/models/intermediate/_intermediate_models.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ models:
- name: bbl
- name: block_group_geoid
- name: overlap_ratio

- name: int__lot_block_groups
description: >-
unique intersections of pluto lots and census block groups with proportion of lot in block group,
Expand All @@ -45,6 +45,12 @@ models:
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns: [bbl, block_group_geoid]
- sum_by:
group_by: bbl
target_column: overlap_ratio
val: 1
config:
severity: warn

- name: int__tracts
description: residential area and low-to-moderate income data aggregated by census tract
Expand Down

0 comments on commit 5514820

Please sign in to comment.