Merged PR 3235: Ensure values to be treated as decimals

# Description

Small PR to ensure all values within the computation will be treated as decimals. I apply this at the beginning of the code for the 4 main inputs used. This avoids later integer divisions.

# Checklist

- [X] The edited models and dependants run properly with production data.
- [X] The edited models are sufficiently documented.
- [X] The edited models contain PK tests, and I've ran and passed them.
- [NA] I have checked for DRY opportunities with other models and docs.
- [NA] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #22691
This commit is contained in:
Oriol Roqué Paniagua 2024-10-18 08:14:24 +00:00
parent d475285461
commit b9ca7c5e8c

View file

@ -8,22 +8,22 @@ with
am.date,
am.id_deal,
am.deal_lifecycle_state,
count(*) over (
1.0 * count(*) over (
partition by am.id_deal
order by am.date
rows between 12 preceding and 1 preceding
) as preceding_months_count_by_deal,
sum(am.total_revenue_in_gbp) over (
1.0 * sum(am.total_revenue_in_gbp) over (
partition by am.id_deal
order by am.date
rows between 12 preceding and 1 preceding
) as sum_total_revenue_preceding_12_months,
sum(am.created_bookings) over (
1.0 * sum(am.created_bookings) over (
partition by am.id_deal
order by am.date
rows between 12 preceding and 1 preceding
) as sum_created_bookings_preceding_12_months,
sum(am.listings_booked_in_month) over (
1.0 * sum(am.listings_booked_in_month) over (
partition by am.id_deal
order by am.date
rows between 12 preceding and 1 preceding