Merged PR 4839: Fixed weekly and monthly granularity

# Description

Fixed weekly and monthly granularity where previously I wasn't filtering `end_of_week` or `end_of_month` dates for these granularities

# 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.
- [ ] I have checked for DRY opportunities with other models and docs.
- [ ] I've picked the right materialization for the affected models.

# Other

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

Fixed weekly and monthly granularity

Related work items: #28640
This commit is contained in:
Joaquin Ossa 2025-03-28 11:02:23 +00:00
commit e844762c23

View file

@ -38,8 +38,10 @@ with
select *
from {{ ref("int_kpis__agg_monthly_new_dash_accommodation_offered_services") }}
),
int_kpis__dimension_dates as (select * from {{ ref("int_kpis__dimension_dates") }}),
all_dates as (
select distinct date, dimension, dimension_value
select distinct
c.date, c.dimension, c.dimension_value, d.is_end_of_week, d.is_end_of_month
from
(
select date, dimension, dimension_value
@ -53,7 +55,8 @@ with
union all
select date, dimension, dimension_value
from int_kpis__agg_daily_new_dash_accommodation_offered_services
) combined
) c
left join int_kpis__dimension_dates d on c.date = d.date
)
select
d.date,
@ -140,6 +143,7 @@ left join
on created.end_date = accommodation.date
and created.dimension = accommodation.dimension
and created.dimension_value = accommodation.dimension_value
where d.is_end_of_week
union all
select
d.date,
@ -183,3 +187,4 @@ left join
on created.end_date = accommodation.date
and created.dimension = accommodation.dimension
and created.dimension_value = accommodation.dimension_value
where d.is_end_of_month