Modified name and changed date to group as an argument
This commit is contained in:
parent
0f5eb5fba2
commit
658980e48f
2 changed files with 38 additions and 16 deletions
|
|
@ -1,13 +1,13 @@
|
||||||
{% test kpis_outlier_detector(
|
{% test kpis_daily_outlier_detector(
|
||||||
model, column_name, sigma_threshold=3, days_to_consider=14
|
model, date_column, column_name, sigma_threshold=3, days_to_consider=14
|
||||||
) %}
|
) %}
|
||||||
with
|
with
|
||||||
-- Retrieve recent data based on the defined days_to_consider
|
-- Retrieve recent data based on the defined days_to_consider
|
||||||
recent_data as (
|
recent_data as (
|
||||||
select date_day, {{ column_name }}
|
select {{ date_column }}, {{ column_name }}
|
||||||
from {{ model }}
|
from {{ model }}
|
||||||
where
|
where
|
||||||
date_day between (
|
{{ date_column }} between (
|
||||||
current_date - interval '{{ days_to_consider + 1 }} days'
|
current_date - interval '{{ days_to_consider + 1 }} days'
|
||||||
) and (current_date - interval '1 day')
|
) and (current_date - interval '1 day')
|
||||||
),
|
),
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
> {{ sigma_threshold }} as is_outlier
|
> {{ sigma_threshold }} as is_outlier
|
||||||
from {{ model }}
|
from {{ model }}
|
||||||
cross join metrics_stats
|
cross join metrics_stats
|
||||||
where date_day = current_date - interval '1 day'
|
where {{ date_column }} = current_date - interval '1 day'
|
||||||
)
|
)
|
||||||
-- Return failing rows if any values are flagged as outliers
|
-- Return failing rows if any values are flagged as outliers
|
||||||
select *
|
select *
|
||||||
|
|
@ -67,7 +67,9 @@ models:
|
||||||
Count of daily guest journeys created, excluding cancelled bookings,
|
Count of daily guest journeys created, excluding cancelled bookings,
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: created_guest_journeys_not_cancelled
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: started_guest_journeys_not_cancelled
|
- name: started_guest_journeys_not_cancelled
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -75,7 +77,9 @@ models:
|
||||||
Count of daily guest journeys started, excluding cancelled bookings,
|
Count of daily guest journeys started, excluding cancelled bookings,
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: started_guest_journeys_not_cancelled
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: completed_guest_journeys_not_cancelled
|
- name: completed_guest_journeys_not_cancelled
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -83,7 +87,9 @@ models:
|
||||||
Count of daily guest journeys completed, excluding cancelled bookings,
|
Count of daily guest journeys completed, excluding cancelled bookings,
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: completed_guest_journeys_not_cancelled
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: created_guest_journeys
|
- name: created_guest_journeys
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -91,7 +97,9 @@ models:
|
||||||
Count of daily guest journeys created in a given date and
|
Count of daily guest journeys created in a given date and
|
||||||
per specified dimension.
|
per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: created_guest_journeys
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: started_guest_journeys
|
- name: started_guest_journeys
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -99,7 +107,9 @@ models:
|
||||||
Count of daily guest journeys started in a given date and
|
Count of daily guest journeys started in a given date and
|
||||||
per specified dimension.
|
per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: started_guest_journeys
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: completed_guest_journeys
|
- name: completed_guest_journeys
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -107,7 +117,9 @@ models:
|
||||||
Count of daily guest journeys completed in a given date and
|
Count of daily guest journeys completed in a given date and
|
||||||
per specified dimension.
|
per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: completed_guest_journeys
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: total_csat_score_count
|
- name: total_csat_score_count
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -115,7 +127,9 @@ models:
|
||||||
Count of daily guest journeys with CSAT (customer satisfaction score)
|
Count of daily guest journeys with CSAT (customer satisfaction score)
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: total_csat_score_count
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: average_csat_score
|
- name: average_csat_score
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
@ -128,7 +142,9 @@ models:
|
||||||
Sum of deposit fees paid by guests, without taxes, in GBP
|
Sum of deposit fees paid by guests, without taxes, in GBP
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: deposit_fees_in_gbp
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: waiver_payments_in_gbp
|
- name: waiver_payments_in_gbp
|
||||||
data_type: decimal
|
data_type: decimal
|
||||||
|
|
@ -136,7 +152,9 @@ models:
|
||||||
Sum of waiver payments paid by guests, without taxes, in GBP
|
Sum of waiver payments paid by guests, without taxes, in GBP
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: waiver_payments_in_gbp
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: checkin_cover_fees_in_gbp
|
- name: checkin_cover_fees_in_gbp
|
||||||
data_type: decimal
|
data_type: decimal
|
||||||
|
|
@ -144,7 +162,9 @@ models:
|
||||||
Sum of checkin cover fees paid by guests, without taxes, in GBP
|
Sum of checkin cover fees paid by guests, without taxes, in GBP
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: checkin_cover_fees_in_gbp
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: total_guest_payments_in_gbp
|
- name: total_guest_payments_in_gbp
|
||||||
data_type: decimal
|
data_type: decimal
|
||||||
|
|
@ -152,7 +172,9 @@ models:
|
||||||
Sum of total payments paid by guests, without taxes, in GBP
|
Sum of total payments paid by guests, without taxes, in GBP
|
||||||
in a given date and per specified dimension.
|
in a given date and per specified dimension.
|
||||||
tests:
|
tests:
|
||||||
- kpis_outlier_detector
|
- kpis_daily_outlier_detector:
|
||||||
|
column_name: total_guest_payments_in_gbp
|
||||||
|
date_column: date_day
|
||||||
|
|
||||||
- name: py_created_guest_journeys_not_cancelled
|
- name: py_created_guest_journeys_not_cancelled
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue