ccao-data / data-architecture

Codebase for CCAO data infrastructure construction and management
https://ccao-data.github.io/data-architecture/
5 stars 3 forks source link

Address `NULL` values for `iasworld.sales.nopar` in construction of `default.vw_pin_sale.is_multisale` #336

Closed wrridgeway closed 3 months ago

wrridgeway commented 3 months ago

There are 8 rows in iasworld.sales with NULL values for nopar that don't get properly handled during the construction of is_multisale in default.vw_pin_sale.

wrridgeway commented 3 months ago
with correct as (
select
    'now' as new,
    (num_parcels_sale > 1 and is_multisale) OR (num_parcels_sale = 1 and NOT is_multisale) as "multi_sale matches num_parcels_sale"
from "z_ci_335-address-null-values-for-iasworldsalesnopar-in-construction-of-defaultvw-pin-saleis-multisale_default".vw_pin_sale

UNION ALL

select
    'before' as new,
    (num_parcels_sale > 1 and is_multisale) OR (num_parcels_sale = 1 and NOT is_multisale) as correct
from default.vw_pin_sale
)

select new, "multi_sale matches num_parcels_sale", count(*) as count from correct
group by "multi_sale matches num_parcels_sale", new
order by new
new multi_sale matches num_parcels_sale count
before FALSE 4
before TRUE 2496069
now TRUE 2496073
wrridgeway commented 3 months ago

image