Merged PR 4817: Aggregated models for New Dash improvement
# Description Aggregated models for New Dash improvement. Added daily, weekly and monthly aggregated models for both deals and listings # 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. - [x] I have checked for DRY opportunities with other models and docs. - [x] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #28640
This commit is contained in:
commit
8c3a32d62e
8 changed files with 480 additions and 2 deletions
|
|
@ -134,7 +134,7 @@ Provides a general assignement for the Dimensions available for each KPI
|
||||||
{% set additional_dimensions = [] %}
|
{% set additional_dimensions = [] %}
|
||||||
|
|
||||||
{# Adds Deal dimension to all models except DEAL metrics #}
|
{# Adds Deal dimension to all models except DEAL metrics #}
|
||||||
{% if entity_name != "DEALS" %}
|
{% if entity_name not in ["DEALS", "NEW_DASH_DEALS_OFFERED_SERVICES"] %}
|
||||||
{% set additional_dimensions = additional_dimensions + [dim_deal()] %}
|
{% set additional_dimensions = additional_dimensions + [dim_deal()] %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
@ -188,6 +188,24 @@ Provides a general assignement for the Dimensions available for each KPI
|
||||||
] %}
|
] %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
{% if entity_name == "NEW_DASH_DEALS_OFFERED_SERVICES" %}
|
||||||
|
{% set additional_dimensions = additional_dimensions + [
|
||||||
|
dim_has_upgraded_service(),
|
||||||
|
dim_new_dash_version(),
|
||||||
|
dim_pricing_service(),
|
||||||
|
dim_pricing_business_type(),
|
||||||
|
] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if entity_name == "NEW_DASH_ACCOMMODATION_OFFERED_SERVICES" %}
|
||||||
|
{% set additional_dimensions = additional_dimensions + [
|
||||||
|
dim_has_upgraded_service(),
|
||||||
|
dim_new_dash_version(),
|
||||||
|
dim_pricing_service(),
|
||||||
|
dim_pricing_business_type(),
|
||||||
|
] %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{# Combine base dimensions with additional dimensions for the specific model #}
|
{# Combine base dimensions with additional dimensions for the specific model #}
|
||||||
{% set dimensions = base_dimensions + additional_dimensions %}
|
{% set dimensions = base_dimensions + additional_dimensions %}
|
||||||
{{ return(dimensions) }}
|
{{ return(dimensions) }}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model(
|
||||||
|
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||||
|
) %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct aos.id_accommodation) as accommodation_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }}
|
||||||
|
as aos
|
||||||
|
on d.date = aos.date
|
||||||
|
where aos.id_accommodation is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct dos.id_deal) as deal_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos
|
||||||
|
on d.date = dos.date
|
||||||
|
where dos.id_deal is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model(
|
||||||
|
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||||
|
) %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct aos.id_accommodation) as accommodation_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }}
|
||||||
|
as aos
|
||||||
|
on aos.date = d.date
|
||||||
|
where d.is_end_of_month = true and aos.id_accommodation is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct dos.id_deal) as deal_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos
|
||||||
|
on dos.date = d.date
|
||||||
|
where d.is_end_of_month = true and dos.id_deal is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,26 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model(
|
||||||
|
"NEW_DASH_ACCOMMODATION_OFFERED_SERVICES"
|
||||||
|
) %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct aos.id_accommodation) as accommodation_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_accommodation_offered_services") }}
|
||||||
|
as aos
|
||||||
|
on aos.date = d.date
|
||||||
|
where d.is_end_of_week = true and aos.id_accommodation is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
{% set dimensions = get_kpi_dimensions_per_model("NEW_DASH_DEALS_OFFERED_SERVICES") %}
|
||||||
|
|
||||||
|
{{ config(materialized="table", unique_key=["date", "dimension", "dimension_value"]) }}
|
||||||
|
|
||||||
|
|
||||||
|
{% for dimension in dimensions %}
|
||||||
|
select
|
||||||
|
-- Unique Key --
|
||||||
|
d.date,
|
||||||
|
{{ dimension.dimension }} as dimension,
|
||||||
|
{{ dimension.dimension_value }} as dimension_value,
|
||||||
|
-- Metrics --
|
||||||
|
count(distinct dos.id_deal) as deal_with_offered_service_count
|
||||||
|
from {{ ref("int_kpis__dimension_dates") }} d
|
||||||
|
left join
|
||||||
|
{{ ref("int_kpis__metric_daily_new_dash_deals_offered_services") }} as dos
|
||||||
|
on dos.date = d.date
|
||||||
|
where d.is_end_of_week = true and dos.id_deal is not null
|
||||||
|
group by 1, 2, 3
|
||||||
|
{% if not loop.last %}
|
||||||
|
union all
|
||||||
|
{% endif %}
|
||||||
|
{% endfor %}
|
||||||
|
|
@ -7587,4 +7587,317 @@ models:
|
||||||
description: |
|
description: |
|
||||||
Main billing country of the host aggregated at Deal level.
|
Main billing country of the host aggregated at Deal level.
|
||||||
data_tests:
|
data_tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
|
||||||
|
- name: int_kpis__agg_daily_new_dash_deals_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Daily Deals Offered Services.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The daily date acting as time range for the metrics in this record.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- deal_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: deal_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The daily count of deals with services offered for a given date, dimension and value.
|
||||||
|
|
||||||
|
- name: int_kpis__agg_weekly_new_dash_deals_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Number of Deals with
|
||||||
|
Offered Services by the end of each week.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The end date of the week.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- deal_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: deal_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The count of deals with services offered by the end of a given week, dimension and value.
|
||||||
|
|
||||||
|
- name: int_kpis__agg_monthly_new_dash_deals_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Number of Deals with
|
||||||
|
Offered Services by the end of each month.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The end date of the month.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- deal_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: deal_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The count of deals with services offered by the end of a given month, dimension and value.
|
||||||
|
|
||||||
|
- name: int_kpis__agg_daily_new_dash_accommodation_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Daily Accommodation Offered Services.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The daily date acting as time range for the metrics in this record.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- accommodation_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_deal
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: accommodation_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The daily count of accommodations with services offered for a given date, dimension and value.
|
||||||
|
|
||||||
|
- name: int_kpis__agg_weekly_new_dash_accommodation_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Number of Accommodation with
|
||||||
|
Offered Services by the end of each week.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The end date of the week.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- accommodation_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_deal
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: accommodation_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The count of accommodations with services offered by the end of a given week, dimension and value.
|
||||||
|
|
||||||
|
- name: int_kpis__agg_monthly_new_dash_accommodation_offered_services
|
||||||
|
description: |
|
||||||
|
This model computes the dimension aggregation for Number of Accommodation with
|
||||||
|
Offered Services by the end of each month.
|
||||||
|
It only retrieves services that come from users that are in New Dash, as well
|
||||||
|
as it only considers services created after the user has moved to New Dash.
|
||||||
|
The primary key of this model is date, dimension and dimension_value.
|
||||||
|
|
||||||
|
data_tests:
|
||||||
|
- dbt_utils.unique_combination_of_columns:
|
||||||
|
combination_of_columns:
|
||||||
|
- date
|
||||||
|
- dimension
|
||||||
|
- dimension_value
|
||||||
|
|
||||||
|
columns:
|
||||||
|
- name: date
|
||||||
|
data_type: date
|
||||||
|
description: |
|
||||||
|
The end date of the month.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: dimension
|
||||||
|
data_type: string
|
||||||
|
description: The dimension or granularity of the metrics.
|
||||||
|
data_tests:
|
||||||
|
- assert_dimension_completeness:
|
||||||
|
metric_column_names:
|
||||||
|
- accommodation_with_offered_service_count
|
||||||
|
where: "dimension in ('by_number_of_listings', 'by_billing_country', 'by_new_dash_version', 'by_deal')"
|
||||||
|
- accepted_values:
|
||||||
|
values:
|
||||||
|
- global
|
||||||
|
- by_number_of_listings
|
||||||
|
- by_billing_country
|
||||||
|
- by_new_dash_version
|
||||||
|
- by_deal
|
||||||
|
- by_has_upgraded_service
|
||||||
|
- by_service
|
||||||
|
- by_service_business_type
|
||||||
|
|
||||||
|
- name: dimension_value
|
||||||
|
data_type: string
|
||||||
|
description: The value or segment available for the selected dimension.
|
||||||
|
data_tests:
|
||||||
|
- not_null
|
||||||
|
|
||||||
|
- name: accommodation_with_offered_service_count
|
||||||
|
data_type: bigint
|
||||||
|
description: |
|
||||||
|
The count of accommodations with services offered by the end of a given month, dimension and value.
|
||||||
Loading…
Add table
Add a link
Reference in a new issue