data alert fix

This commit is contained in:
Joaquin 2025-06-10 13:58:50 +02:00
parent dc0abe6098
commit e85de15d22
4 changed files with 25 additions and 47 deletions

View file

@ -16,11 +16,11 @@ with
select
*,
row_number() over (
partition by id_accommodation, effective_start_date_utc
partition by id_accommodation, starts_date_utc
order by
effective_start_date_utc desc, -- Prefers the latest effective start date
original_starts_at_utc desc, -- In case of ties, prefers the most recent original start
coalesce(original_ends_at_utc, {{ var("end_of_time") }}) desc
starts_date_utc desc, -- Prefers the latest effective start date
starts_at_utc desc, -- In case of ties, prefers the most recent original start
coalesce(ends_at_utc, {{ var("end_of_time") }}) desc
) as rn
from {{ ref("int_core__accommodation_to_product_bundle") }}
)
@ -51,8 +51,8 @@ inner join
inner join
latest_daily_bundle as ldb
on bs.id_user_product_bundle = ldb.id_user_product_bundle
and date >= ldb.effective_start_date_utc
and date < coalesce(ldb.effective_end_date_utc, {{ var("end_of_time") }})
and date >= ldb.starts_date_utc
and (date < ldb.ends_date_utc or ldb.has_no_end_date = true)
and ldb.rn = 1
left join
{{ ref("int_kpis__dimension_daily_accommodation") }} as icmas