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:
commit
e844762c23
1 changed files with 7 additions and 2 deletions
|
|
@ -38,8 +38,10 @@ with
|
||||||
select *
|
select *
|
||||||
from {{ ref("int_kpis__agg_monthly_new_dash_accommodation_offered_services") }}
|
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 (
|
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
|
from
|
||||||
(
|
(
|
||||||
select date, dimension, dimension_value
|
select date, dimension, dimension_value
|
||||||
|
|
@ -53,7 +55,8 @@ with
|
||||||
union all
|
union all
|
||||||
select date, dimension, dimension_value
|
select date, dimension, dimension_value
|
||||||
from int_kpis__agg_daily_new_dash_accommodation_offered_services
|
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
|
select
|
||||||
d.date,
|
d.date,
|
||||||
|
|
@ -140,6 +143,7 @@ left join
|
||||||
on created.end_date = accommodation.date
|
on created.end_date = accommodation.date
|
||||||
and created.dimension = accommodation.dimension
|
and created.dimension = accommodation.dimension
|
||||||
and created.dimension_value = accommodation.dimension_value
|
and created.dimension_value = accommodation.dimension_value
|
||||||
|
where d.is_end_of_week
|
||||||
union all
|
union all
|
||||||
select
|
select
|
||||||
d.date,
|
d.date,
|
||||||
|
|
@ -183,3 +187,4 @@ left join
|
||||||
on created.end_date = accommodation.date
|
on created.end_date = accommodation.date
|
||||||
and created.dimension = accommodation.dimension
|
and created.dimension = accommodation.dimension
|
||||||
and created.dimension_value = accommodation.dimension_value
|
and created.dimension_value = accommodation.dimension_value
|
||||||
|
where d.is_end_of_month
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue