Merged PR 3672: fixed outlier_detector

# Description

PR to fix the kpis_daily_outlier_detector test.
Previously it was using all values for the metric independently of the granularity, now is adding them up by daily value and no other metrics.

# Checklist

- [x] The edited models and dependants run properly with production data.
- [ ] 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 outlier_detector

Related work items: #24590
This commit is contained in:
Joaquin Ossa 2024-11-26 15:37:08 +00:00
commit 0668c0beb4

View file

@ -4,12 +4,13 @@
with
-- Retrieve recent data based on the defined days_to_consider
recent_data as (
select {{ date_column }}, {{ column_name }}
select {{ date_column }}, sum({{ column_name }}) as {{ column_name }}
from {{ model }}
where
{{ date_column }} between (
current_date - interval '{{ days_to_consider + 1 }} days'
) and (current_date - interval '1 day')
group by {{ date_column }}
),
metrics_stats as (
select