-- Staged TRREB purchase/sales data
-- Source: fact_purchases table loaded from TRREB Market Watch PDFs
-- Grain: One row per district per month

with source as (
    select * from {{ source('toronto_housing', 'fact_purchases') }}
),

staged as (
    select
        id as purchase_id,
        date_key,
        district_key,
        sales_count,
        dollar_volume,
        avg_price,
        median_price,
        new_listings,
        active_listings,
        avg_dom as days_on_market,
        avg_sp_lp as sale_to_list_ratio
    from source
)

select * from staged
