Revert cross models

This commit is contained in:
Joaquin 2024-11-05 12:37:31 +01:00
parent 092e37d58c
commit 5bcfd7cb9c
8 changed files with 18 additions and 18 deletions

View file

@ -1,7 +1,7 @@
{{ config(materialized="table", unique_key=["date", "id_deal"]) }} {{ config(materialized="table", unique_key=["date", "id_deal"]) }}
with with
int_monthly_agg_metrics_history_by_deal as ( int_monthly_aggregated_metrics_history_by_deal as (
select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }}
), ),
agg_metrics_by_deal_over_12_months as ( agg_metrics_by_deal_over_12_months as (
select select
@ -28,7 +28,7 @@ with
order by am.date order by am.date
rows between 12 preceding and 1 preceding rows between 12 preceding and 1 preceding
) as sum_listings_booked_in_month_preceding_12_months ) as sum_listings_booked_in_month_preceding_12_months
from int_monthly_agg_metrics_history_by_deal am from int_monthly_aggregated_metrics_history_by_deal am
), ),
global_computation_over_12_months as ( global_computation_over_12_months as (
select select

View file

@ -1,7 +1,7 @@
{{ config(materialized="table", unique_key=["date", "id_deal"]) }} {{ config(materialized="table", unique_key=["date", "id_deal"]) }}
with with
int_monthly_agg_metrics_history_by_deal as ( int_monthly_aggregated_metrics_history_by_deal as (
select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }}
), ),
int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }}), int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }}),
deal_history_from_previous_months as ( deal_history_from_previous_months as (
@ -17,7 +17,7 @@ with
coalesce(total_revenue_in_gbp, 0) as revenue_in_gbp, coalesce(total_revenue_in_gbp, 0) as revenue_in_gbp,
coalesce(created_bookings, 0) as created_bookings, coalesce(created_bookings, 0) as created_bookings,
coalesce(listings_booked_in_month, 0) as listings_booked_in_month coalesce(listings_booked_in_month, 0) as listings_booked_in_month
from int_monthly_agg_metrics_history_by_deal am from int_monthly_aggregated_metrics_history_by_deal am
-- Do not show data of ongoing month -- Do not show data of ongoing month
where am.date < date_trunc('month', current_date)::date where am.date < date_trunc('month', current_date)::date
), ),

View file

@ -113,8 +113,8 @@ exposures:
Additionally, it allows to retrieve similar KPIs at Deal level. Additionally, it allows to retrieve similar KPIs at Deal level.
depends_on: depends_on:
- ref('mtd_agg_metrics') - ref('mtd_aggregated_metrics')
- ref('monthly_agg_metrics_history_by_deal') - ref('monthly_aggregated_metrics_history_by_deal')
owner: owner:
name: Oriol Roqué name: Oriol Roqué

View file

@ -1,6 +1,6 @@
with with
int_monthly_agg_metrics_history_by_deal as ( int_monthly_aggregated_metrics_history_by_deal as (
select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }}
) )
select select
@ -113,4 +113,4 @@ select
deposit_fees_in_gbp as deposit_fees_in_gbp, deposit_fees_in_gbp as deposit_fees_in_gbp,
waiver_payments_in_gbp as waiver_payments_in_gbp, waiver_payments_in_gbp as waiver_payments_in_gbp,
checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp
from int_monthly_agg_metrics_history_by_deal from int_monthly_aggregated_metrics_history_by_deal

View file

@ -11,9 +11,9 @@ with
{% endif %} {% endif %}
{% endfor %} {% endfor %}
), ),
int_mtd_agg_metrics as ( int_mtd_aggregated_metrics as (
select m.*, d.dimension_display select m.*, d.dimension_display
from {{ ref("int_mtd_agg_metrics") }} m from {{ ref("int_mtd_aggregated_metrics") }} m
-- The following clause limits the display execution -- The following clause limits the display execution
-- to only include those dimensions configured to -- to only include those dimensions configured to
-- appear for production purposes -- appear for production purposes
@ -38,7 +38,7 @@ select
previous_year_value as previous_year_value, previous_year_value as previous_year_value,
relative_increment as relative_increment, relative_increment as relative_increment,
relative_increment_with_sign_format as relative_increment_with_sign_format relative_increment_with_sign_format as relative_increment_with_sign_format
from int_mtd_agg_metrics from int_mtd_aggregated_metrics
/* /*
The following where condition is applied to avoid displaying revenue metrics The following where condition is applied to avoid displaying revenue metrics
in the MTD for the current month and the previous month. The main reason is in the MTD for the current month and the previous month. The main reason is

View file

@ -307,7 +307,7 @@ models:
tests: tests:
- not_null - not_null
- name: mtd_agg_metrics - name: mtd_aggregated_metrics
description: | description: |
This model aggregates the historic information of our business by providing This model aggregates the historic information of our business by providing
different metrics computed at global and dimension level. different metrics computed at global and dimension level.
@ -447,19 +447,19 @@ models:
positive impact for Superhog, otherwise is equal to relative_increment. positive impact for Superhog, otherwise is equal to relative_increment.
This value is specially created for formatting in PBI This value is specially created for formatting in PBI
- name: monthly_agg_metrics_history_by_deal - name: monthly_aggregated_metrics_history_by_deal
description: | description: |
This model aggregates the monthly historic information regarding the different metrics computed This model aggregates the monthly historic information regarding the different metrics computed
at deal level. The primary source of data is the `int_monthly_XXXXX_history_by_deal` at deal level. The primary source of data is the `int_monthly_XXXXX_history_by_deal`
model which contain the raw metrics data per source. model which contain the raw metrics data per source.
This table is used to provide "By Deal" metrics in the Business Overview reporting. This table is used to provide "By Deal" metrics in the Business Overview reporting.
Unlike the mtd_agg_metrics, this model does not abstract each metric, since Unlike the mtd_aggregated_metrics, this model does not abstract each metric, since
no comparison versus last year is performed. In short, it just gathers the information stored no comparison versus last year is performed. In short, it just gathers the information stored
in the abovementioned models. in the abovementioned models.
To keep in mind: aggregating the information of this model will not necessarily result into To keep in mind: aggregating the information of this model will not necessarily result into
the int_mtd_agg_metrics because 1) the mtd version contains more computing dates the int_mtd_aggregated_metrics because 1) the mtd version contains more computing dates
than the by deal version, the latest being a subset of the first, and 2) the deal based model than the by deal version, the latest being a subset of the first, and 2) the deal based model
enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is
not necessarily the case. not necessarily the case.