From 8d834e06d6bea53259ad536b1cfd31f7779fb13c Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 16:41:30 +0000 Subject: [PATCH 01/17] Initial commit --- .../reporting/reporting.vw_ratio_curves.sql | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 dbt/models/reporting/reporting.vw_ratio_curves.sql diff --git a/dbt/models/reporting/reporting.vw_ratio_curves.sql b/dbt/models/reporting/reporting.vw_ratio_curves.sql new file mode 100644 index 000000000..3afeeb006 --- /dev/null +++ b/dbt/models/reporting/reporting.vw_ratio_curves.sql @@ -0,0 +1,58 @@ +-- Final model run IDs by township and year +WITH final_models AS ( + SELECT + final_model.run_id, + towns.township_code + FROM {{ source('model', 'final_model') }} AS final_model + CROSS JOIN + UNNEST(final_model.township_code_coverage) AS towns (township_code) + -- Year will need to be adjusted so that desk review to model values join in + -- R script is 1 to 1. + WHERE CAST(final_model.year AS INT) = YEAR(CURRENT_DATE) + AND final_model.type = 'res' +), + +-- Use final model run IDs to grab the model values we need to compare Res Val's +-- desk review values against +model_vals AS ( + SELECT + assessment_pin.meta_pin AS pin, + assessment_pin.pred_pin_final_fmv_round AS model_value, + assessment_pin.sale_ratio_study_price AS sale_price, + assessment_pin.sale_ratio_study_date AS sale_date, + assessment_pin.sale_ratio_study_document_num AS sale_document_number + FROM {{ source('model', 'assessment_pin') }} AS assessment_pin + INNER JOIN final_models + ON assessment_pin.run_id = final_models.run_id + AND assessment_pin.township_code = final_models.township_code +), + +-- Res Val provides PINs that sometimes only appear in 2025 or 2026 in +-- default.vw_pin_universe. Make sure we grab one and only one row for every PIN +-- that appears in either year, regardless of whether they have a model value. +most_recent_pin AS ( + SELECT + uni.pin, + uni.township_name, + uni.nbhd_code AS neighborhood_number, + ROW_NUMBER() OVER ( + PARTITION BY + uni.pin + ORDER BY uni.year DESC + ) AS rank + FROM {{ ref('default.vw_pin_universe') }} AS uni + WHERE CAST(uni.year AS INT) IN (YEAR(CURRENT_DATE) - 1, YEAR(CURRENT_DATE)) +) + +SELECT + vpu.pin, + vpu.township_name, + vpu.neighborhood_number, + model_vals.model_value, + model_vals.sale_price, + model_vals.sale_date, + model_vals.sale_document_number +FROM most_recent_pin AS vpu +LEFT JOIN model_vals + ON vpu.pin = model_vals.pin +WHERE vpu.rank = 1 From fc481b00fccabac4797faced0e30ba4625bbc0de Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 17:24:57 +0000 Subject: [PATCH 02/17] Rename view --- ...porting.vw_ratio_curves.sql => reporting.vw_ratio_curve.sql} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename dbt/models/reporting/{reporting.vw_ratio_curves.sql => reporting.vw_ratio_curve.sql} (97%) diff --git a/dbt/models/reporting/reporting.vw_ratio_curves.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql similarity index 97% rename from dbt/models/reporting/reporting.vw_ratio_curves.sql rename to dbt/models/reporting/reporting.vw_ratio_curve.sql index 3afeeb006..60f525306 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curves.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -3,7 +3,7 @@ WITH final_models AS ( SELECT final_model.run_id, towns.township_code - FROM {{ source('model', 'final_model') }} AS final_model + FROM {{ ref('model.final_model') }} AS final_model CROSS JOIN UNNEST(final_model.township_code_coverage) AS towns (township_code) -- Year will need to be adjusted so that desk review to model values join in From c8a3440aa26c599bb491dd4f4b3aa171e7bd7a03 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 17:40:14 +0000 Subject: [PATCH 03/17] Add desk review values --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 60f525306..5d80b2771 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -35,6 +35,7 @@ most_recent_pin AS ( uni.pin, uni.township_name, uni.nbhd_code AS neighborhood_number, + CAST(YEAR(CURRENT_DATE) AS VARCHAR) AS year, ROW_NUMBER() OVER ( PARTITION BY uni.pin @@ -48,6 +49,7 @@ SELECT vpu.pin, vpu.township_name, vpu.neighborhood_number, + vpv.pre_mailed_tot AS desk_review_value, model_vals.model_value, model_vals.sale_price, model_vals.sale_date, @@ -55,4 +57,7 @@ SELECT FROM most_recent_pin AS vpu LEFT JOIN model_vals ON vpu.pin = model_vals.pin +LEFT JOIN {{ ref('default.vw_pin_value') }} AS vpv + ON vpu.pin = vpv.pin + AND vpv.year = vpu.year WHERE vpu.rank = 1 From db5847b58f1c2cd4f094a6a3576ca97fd806e03a Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 18:19:21 +0000 Subject: [PATCH 04/17] Trim sample --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 5d80b2771..b64adb606 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -33,6 +33,7 @@ model_vals AS ( most_recent_pin AS ( SELECT uni.pin, + uni.class, uni.township_name, uni.nbhd_code AS neighborhood_number, CAST(YEAR(CURRENT_DATE) AS VARCHAR) AS year, @@ -49,7 +50,7 @@ SELECT vpu.pin, vpu.township_name, vpu.neighborhood_number, - vpv.pre_mailed_tot AS desk_review_value, + vpv.pre_mailed_tot * 10 AS desk_review_value, model_vals.model_value, model_vals.sale_price, model_vals.sale_date, @@ -59,5 +60,7 @@ LEFT JOIN model_vals ON vpu.pin = model_vals.pin LEFT JOIN {{ ref('default.vw_pin_value') }} AS vpv ON vpu.pin = vpv.pin - AND vpv.year = vpu.year + AND vpu.year = vpv.year WHERE vpu.rank = 1 + AND SUBSTR(vpv.pre_mailed_class, 1, 1) = '2' + AND vpv.pre_mailed_tot IS NOT NULL From 8e085b98f882cbc28052602d8638256e0aaafe0c Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 18:36:32 +0000 Subject: [PATCH 05/17] Trim sample more intelligently --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index b64adb606..010191f82 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -33,7 +33,6 @@ model_vals AS ( most_recent_pin AS ( SELECT uni.pin, - uni.class, uni.township_name, uni.nbhd_code AS neighborhood_number, CAST(YEAR(CURRENT_DATE) AS VARCHAR) AS year, @@ -56,11 +55,10 @@ SELECT model_vals.sale_date, model_vals.sale_document_number FROM most_recent_pin AS vpu -LEFT JOIN model_vals +INNER JOIN model_vals ON vpu.pin = model_vals.pin LEFT JOIN {{ ref('default.vw_pin_value') }} AS vpv ON vpu.pin = vpv.pin AND vpu.year = vpv.year WHERE vpu.rank = 1 - AND SUBSTR(vpv.pre_mailed_class, 1, 1) = '2' AND vpv.pre_mailed_tot IS NOT NULL From 9af402e723604c5ff79f98d79b19535d9382ad9c Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 18:38:59 +0000 Subject: [PATCH 06/17] Switch to inner join --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 010191f82..637435eb1 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -57,8 +57,8 @@ SELECT FROM most_recent_pin AS vpu INNER JOIN model_vals ON vpu.pin = model_vals.pin -LEFT JOIN {{ ref('default.vw_pin_value') }} AS vpv +INNER JOIN {{ ref('default.vw_pin_value') }} AS vpv ON vpu.pin = vpv.pin AND vpu.year = vpv.year -WHERE vpu.rank = 1 AND vpv.pre_mailed_tot IS NOT NULL +WHERE vpu.rank = 1 From f2a548ffc02a7ec9b4dc90508ee3999490cf5d89 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 19:06:10 +0000 Subject: [PATCH 07/17] Cast values as ints --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 637435eb1..d55f259cb 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -49,9 +49,9 @@ SELECT vpu.pin, vpu.township_name, vpu.neighborhood_number, - vpv.pre_mailed_tot * 10 AS desk_review_value, - model_vals.model_value, - model_vals.sale_price, + CAST(vpv.pre_mailed_tot * 10 AS INT) AS desk_review_value, + CAST(model_vals.model_value AS INT) AS model_value, + CAST(model_vals.sale_price AS INT) AS sale_price, model_vals.sale_date, model_vals.sale_document_number FROM most_recent_pin AS vpu From 00fcead19dcb0d3d0388c246977cf4d2893e78e3 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 19:13:52 +0000 Subject: [PATCH 08/17] Switch to bigint --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index d55f259cb..2addc5c97 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -49,9 +49,9 @@ SELECT vpu.pin, vpu.township_name, vpu.neighborhood_number, - CAST(vpv.pre_mailed_tot * 10 AS INT) AS desk_review_value, - CAST(model_vals.model_value AS INT) AS model_value, - CAST(model_vals.sale_price AS INT) AS sale_price, + CAST(vpv.pre_mailed_tot * 10 AS BIGINT) AS desk_review_value, + CAST(model_vals.model_value AS BIGINT) AS model_value, + CAST(model_vals.sale_price AS BIGINT) AS sale_price, model_vals.sale_date, model_vals.sale_document_number FROM most_recent_pin AS vpu From c0d87f9da5de0b9f6e6b991791c885fdc8f881b8 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 19:36:22 +0000 Subject: [PATCH 09/17] Simplify sql query since we're no longer use res val's input --- .../reporting/reporting.vw_ratio_curve.sql | 29 +++++-------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 2addc5c97..0f90d7d88 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -20,45 +20,30 @@ model_vals AS ( assessment_pin.pred_pin_final_fmv_round AS model_value, assessment_pin.sale_ratio_study_price AS sale_price, assessment_pin.sale_ratio_study_date AS sale_date, - assessment_pin.sale_ratio_study_document_num AS sale_document_number + assessment_pin.sale_ratio_study_document_num AS sale_document_number, + assessment_pin.year FROM {{ source('model', 'assessment_pin') }} AS assessment_pin INNER JOIN final_models ON assessment_pin.run_id = final_models.run_id AND assessment_pin.township_code = final_models.township_code -), - --- Res Val provides PINs that sometimes only appear in 2025 or 2026 in --- default.vw_pin_universe. Make sure we grab one and only one row for every PIN --- that appears in either year, regardless of whether they have a model value. -most_recent_pin AS ( - SELECT - uni.pin, - uni.township_name, - uni.nbhd_code AS neighborhood_number, - CAST(YEAR(CURRENT_DATE) AS VARCHAR) AS year, - ROW_NUMBER() OVER ( - PARTITION BY - uni.pin - ORDER BY uni.year DESC - ) AS rank - FROM {{ ref('default.vw_pin_universe') }} AS uni - WHERE CAST(uni.year AS INT) IN (YEAR(CURRENT_DATE) - 1, YEAR(CURRENT_DATE)) ) SELECT vpu.pin, vpu.township_name, - vpu.neighborhood_number, + vpu.nbhd_code AS neighborhood_number, + -- These values are slightly different than the desk review values Res Val + -- provides due to rounding in iasWorld, but the differences are negligible CAST(vpv.pre_mailed_tot * 10 AS BIGINT) AS desk_review_value, CAST(model_vals.model_value AS BIGINT) AS model_value, CAST(model_vals.sale_price AS BIGINT) AS sale_price, model_vals.sale_date, model_vals.sale_document_number -FROM most_recent_pin AS vpu +FROM {{ ref('default.vw_pin_universe') }} AS vpu INNER JOIN model_vals ON vpu.pin = model_vals.pin + AND vpu.year = model_vals.year INNER JOIN {{ ref('default.vw_pin_value') }} AS vpv ON vpu.pin = vpv.pin AND vpu.year = vpv.year AND vpv.pre_mailed_tot IS NOT NULL -WHERE vpu.rank = 1 From 1876a9564da5f3736d4e0595bd04938b4dfc5a9a Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Fri, 10 Apr 2026 19:40:49 +0000 Subject: [PATCH 10/17] Commenting --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 0f90d7d88..3701a3ce3 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -6,8 +6,6 @@ WITH final_models AS ( FROM {{ ref('model.final_model') }} AS final_model CROSS JOIN UNNEST(final_model.township_code_coverage) AS towns (township_code) - -- Year will need to be adjusted so that desk review to model values join in - -- R script is 1 to 1. WHERE CAST(final_model.year AS INT) = YEAR(CURRENT_DATE) AND final_model.type = 'res' ), @@ -40,6 +38,8 @@ SELECT model_vals.sale_date, model_vals.sale_document_number FROM {{ ref('default.vw_pin_universe') }} AS vpu +-- Inner joins to only pull PINs that have both model and desk review values +-- This should also ensure that we are only pulling regression class parcels INNER JOIN model_vals ON vpu.pin = model_vals.pin AND vpu.year = model_vals.year From d471b51d10198c7b7071ce451a9d4e7d23d75e07 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 14:42:55 +0000 Subject: [PATCH 11/17] Commenting --- .../reporting/reporting.vw_ratio_curve.sql | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index 3701a3ce3..f609d762c 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -1,4 +1,5 @@ --- Final model run IDs by township and year +-- In order to compare desk review values against model values, we need final +-- model run IDs by township and year WITH final_models AS ( SELECT final_model.run_id, @@ -10,8 +11,8 @@ WITH final_models AS ( AND final_model.type = 'res' ), --- Use final model run IDs to grab the model values we need to compare Res Val's --- desk review values against +-- Use the final model run IDs to grab the model values we need to compare Res +-- Val's desk review values against model_vals AS ( SELECT assessment_pin.meta_pin AS pin, @@ -19,13 +20,17 @@ model_vals AS ( assessment_pin.sale_ratio_study_price AS sale_price, assessment_pin.sale_ratio_study_date AS sale_date, assessment_pin.sale_ratio_study_document_num AS sale_document_number, - assessment_pin.year + assessment_pin.year, + assessment_pin.run_id FROM {{ source('model', 'assessment_pin') }} AS assessment_pin INNER JOIN final_models ON assessment_pin.run_id = final_models.run_id AND assessment_pin.township_code = final_models.township_code ) +-- We are not using the most_recent_pin CTE from the recurring data reqeuests +-- analysis since we can't really explain why res val provides PINs that only +-- appear in the prior year SELECT vpu.pin, vpu.township_name, @@ -36,7 +41,8 @@ SELECT CAST(model_vals.model_value AS BIGINT) AS model_value, CAST(model_vals.sale_price AS BIGINT) AS sale_price, model_vals.sale_date, - model_vals.sale_document_number + model_vals.sale_document_number, + model_vals.run_id FROM {{ ref('default.vw_pin_universe') }} AS vpu -- Inner joins to only pull PINs that have both model and desk review values -- This should also ensure that we are only pulling regression class parcels From 02d883d3213774b89cf9d8b9c751a9d834a0023c Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 14:47:25 +0000 Subject: [PATCH 12/17] Reorder columns --- dbt/models/reporting/reporting.vw_ratio_curve.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.vw_ratio_curve.sql index f609d762c..147ed0a6e 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.vw_ratio_curve.sql @@ -39,10 +39,10 @@ SELECT -- provides due to rounding in iasWorld, but the differences are negligible CAST(vpv.pre_mailed_tot * 10 AS BIGINT) AS desk_review_value, CAST(model_vals.model_value AS BIGINT) AS model_value, + model_vals.run_id, CAST(model_vals.sale_price AS BIGINT) AS sale_price, model_vals.sale_date, - model_vals.sale_document_number, - model_vals.run_id + model_vals.sale_document_number FROM {{ ref('default.vw_pin_universe') }} AS vpu -- Inner joins to only pull PINs that have both model and desk review values -- This should also ensure that we are only pulling regression class parcels From d0d9d9e14e3e5ddd8a1010efd2520f6c17796bdf Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 15:01:32 +0000 Subject: [PATCH 13/17] Add ratio columns --- ...io_curve.sql => reporting.ratio_curve.sql} | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) rename dbt/models/reporting/{reporting.vw_ratio_curve.sql => reporting.ratio_curve.sql} (76%) diff --git a/dbt/models/reporting/reporting.vw_ratio_curve.sql b/dbt/models/reporting/reporting.ratio_curve.sql similarity index 76% rename from dbt/models/reporting/reporting.vw_ratio_curve.sql rename to dbt/models/reporting/reporting.ratio_curve.sql index 147ed0a6e..ac4e9e031 100644 --- a/dbt/models/reporting/reporting.vw_ratio_curve.sql +++ b/dbt/models/reporting/reporting.ratio_curve.sql @@ -1,3 +1,13 @@ +-- Gathers model values, pre-mailed (desk review) values, and sale prices for +-- PINs that have both model and desk review values in the current year. Lets us +-- compare sales ratios for model values against desk review values to ensure +-- desk review is improving output. +{{ + config( + materialized='table' + ) +}} + -- In order to compare desk review values against model values, we need final -- model run IDs by township and year WITH final_models AS ( @@ -17,7 +27,7 @@ model_vals AS ( SELECT assessment_pin.meta_pin AS pin, assessment_pin.pred_pin_final_fmv_round AS model_value, - assessment_pin.sale_ratio_study_price AS sale_price, + NULLIF(assessment_pin.sale_ratio_study_price, 0) AS sale_price, assessment_pin.sale_ratio_study_date AS sale_date, assessment_pin.sale_ratio_study_document_num AS sale_document_number, assessment_pin.year, @@ -35,14 +45,18 @@ SELECT vpu.pin, vpu.township_name, vpu.nbhd_code AS neighborhood_number, + COALESCE(model_vals.sale_price IS NOT NULL, FALSE) + AS has_sale, + CAST(model_vals.sale_price AS BIGINT) AS sale_price, + model_vals.sale_date, + model_vals.sale_document_number, -- These values are slightly different than the desk review values Res Val -- provides due to rounding in iasWorld, but the differences are negligible CAST(vpv.pre_mailed_tot * 10 AS BIGINT) AS desk_review_value, + vpv.pre_mailed_tot * 10 / model_vals.sale_price AS desk_review_ratio, CAST(model_vals.model_value AS BIGINT) AS model_value, - model_vals.run_id, - CAST(model_vals.sale_price AS BIGINT) AS sale_price, - model_vals.sale_date, - model_vals.sale_document_number + model_vals.model_value / model_vals.sale_price AS model_ratio, + model_vals.run_id FROM {{ ref('default.vw_pin_universe') }} AS vpu -- Inner joins to only pull PINs that have both model and desk review values -- This should also ensure that we are only pulling regression class parcels From 11f090f0cfaa48c1d9629dd19ea28e7bc1dd4023 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 15:09:40 +0000 Subject: [PATCH 14/17] Add year and triad --- dbt/models/reporting/reporting.ratio_curve.sql | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dbt/models/reporting/reporting.ratio_curve.sql b/dbt/models/reporting/reporting.ratio_curve.sql index ac4e9e031..fe2d33fe2 100644 --- a/dbt/models/reporting/reporting.ratio_curve.sql +++ b/dbt/models/reporting/reporting.ratio_curve.sql @@ -43,8 +43,10 @@ model_vals AS ( -- appear in the prior year SELECT vpu.pin, + vpu.triad_name, vpu.township_name, vpu.nbhd_code AS neighborhood_number, + vpu.year, COALESCE(model_vals.sale_price IS NOT NULL, FALSE) AS has_sale, CAST(model_vals.sale_price AS BIGINT) AS sale_price, From a61f74ff9f0b977723880a7a0b1d9f50a18e9d0d Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 15:11:32 +0000 Subject: [PATCH 15/17] Rename columns --- dbt/models/reporting/reporting.ratio_curve.sql | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dbt/models/reporting/reporting.ratio_curve.sql b/dbt/models/reporting/reporting.ratio_curve.sql index fe2d33fe2..07ac2d3b2 100644 --- a/dbt/models/reporting/reporting.ratio_curve.sql +++ b/dbt/models/reporting/reporting.ratio_curve.sql @@ -43,9 +43,9 @@ model_vals AS ( -- appear in the prior year SELECT vpu.pin, - vpu.triad_name, - vpu.township_name, - vpu.nbhd_code AS neighborhood_number, + vpu.triad_name AS triad, + vpu.township_name AS township, + vpu.nbhd_code AS neighborhood, vpu.year, COALESCE(model_vals.sale_price IS NOT NULL, FALSE) AS has_sale, @@ -58,7 +58,7 @@ SELECT vpv.pre_mailed_tot * 10 / model_vals.sale_price AS desk_review_ratio, CAST(model_vals.model_value AS BIGINT) AS model_value, model_vals.model_value / model_vals.sale_price AS model_ratio, - model_vals.run_id + model_vals.run_id AS model_run_id FROM {{ ref('default.vw_pin_universe') }} AS vpu -- Inner joins to only pull PINs that have both model and desk review values -- This should also ensure that we are only pulling regression class parcels From 452ec135c8016ae9fc73ba5b554260753a7e6fcd Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 15:18:55 +0000 Subject: [PATCH 16/17] Remove current year limit --- dbt/models/reporting/docs.md | 14 ++++++++++++++ dbt/models/reporting/reporting.ratio_curve.sql | 3 +-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/dbt/models/reporting/docs.md b/dbt/models/reporting/docs.md index bd094d35c..ab09c88fe 100644 --- a/dbt/models/reporting/docs.md +++ b/dbt/models/reporting/docs.md @@ -8,6 +8,20 @@ group, township, assessment stage, and year. Feeds public reporting assets. **Primary Key**: `year`, `stage_name`, `geo_id` {% enddocs %} +# ratio_curve + +{% docs table_ratio_curve %} +View for reporting model and desk review ratios by PIN and year. Feeds the desk +review ratio curve dashboard. + +### Assumptions + +- Pre-mailed values match what Res Val used to provide us with as desk review +values. + +**Primary Key**: `year`, `pin` +{% enddocs %} + # ratio_stats {% docs table_ratio_stats %} diff --git a/dbt/models/reporting/reporting.ratio_curve.sql b/dbt/models/reporting/reporting.ratio_curve.sql index 07ac2d3b2..c2bf733fe 100644 --- a/dbt/models/reporting/reporting.ratio_curve.sql +++ b/dbt/models/reporting/reporting.ratio_curve.sql @@ -17,8 +17,7 @@ WITH final_models AS ( FROM {{ ref('model.final_model') }} AS final_model CROSS JOIN UNNEST(final_model.township_code_coverage) AS towns (township_code) - WHERE CAST(final_model.year AS INT) = YEAR(CURRENT_DATE) - AND final_model.type = 'res' + WHERE final_model.type = 'res' ), -- Use the final model run IDs to grab the model values we need to compare Res From 0801b28445723bffbac1e030d74ad8d8415f2126 Mon Sep 17 00:00:00 2001 From: Sweaty Handshake Date: Thu, 23 Apr 2026 15:29:45 +0000 Subject: [PATCH 17/17] Add condos --- dbt/models/reporting/reporting.ratio_curve.sql | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dbt/models/reporting/reporting.ratio_curve.sql b/dbt/models/reporting/reporting.ratio_curve.sql index c2bf733fe..20fe1d611 100644 --- a/dbt/models/reporting/reporting.ratio_curve.sql +++ b/dbt/models/reporting/reporting.ratio_curve.sql @@ -13,11 +13,11 @@ WITH final_models AS ( SELECT final_model.run_id, + final_model.type, towns.township_code FROM {{ ref('model.final_model') }} AS final_model CROSS JOIN UNNEST(final_model.township_code_coverage) AS towns (township_code) - WHERE final_model.type = 'res' ), -- Use the final model run IDs to grab the model values we need to compare Res @@ -30,7 +30,8 @@ model_vals AS ( assessment_pin.sale_ratio_study_date AS sale_date, assessment_pin.sale_ratio_study_document_num AS sale_document_number, assessment_pin.year, - assessment_pin.run_id + assessment_pin.run_id, + final_models.type FROM {{ source('model', 'assessment_pin') }} AS assessment_pin INNER JOIN final_models ON assessment_pin.run_id = final_models.run_id @@ -57,7 +58,8 @@ SELECT vpv.pre_mailed_tot * 10 / model_vals.sale_price AS desk_review_ratio, CAST(model_vals.model_value AS BIGINT) AS model_value, model_vals.model_value / model_vals.sale_price AS model_ratio, - model_vals.run_id AS model_run_id + model_vals.run_id AS model_run_id, + model_vals.type AS model_type FROM {{ ref('default.vw_pin_universe') }} AS vpu -- Inner joins to only pull PINs that have both model and desk review values -- This should also ensure that we are only pulling regression class parcels