From 092e37d58c7696a7cbb4dcd5950023249f325606 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Tue, 5 Nov 2024 12:17:26 +0100 Subject: [PATCH 1/4] aggregated to agg --- ...onthly_12m_window_contribution_by_deal.sql | 10 +-- ...t_monthly_agg_metrics_history_by_deal.sql} | 18 +++--- .../int_monthly_growth_score_by_deal.sql | 64 +++++++++---------- ...ed_metrics.sql => int_mtd_agg_metrics.sql} | 0 .../int_mtd_vs_previous_year_metrics.sql | 36 +++++------ ...t_kpis__agg_monthly_billable_bookings.sql} | 0 ..._kpis__agg_monthly_cancelled_bookings.sql} | 0 ..._kpis__agg_monthly_check_out_bookings.sql} | 0 ..._agg_monthly_completed_guest_journeys.sql} | 0 ...nt_kpis__agg_monthly_created_bookings.sql} | 0 ...s__agg_monthly_created_guest_journeys.sql} | 0 ...g_monthly_guest_journeys_with_payment.sql} | 0 ... int_kpis__agg_monthly_guest_payments.sql} | 0 ...s__agg_monthly_started_guest_journeys.sql} | 0 ...> int_kpis__agg_mtd_billable_bookings.sql} | 0 ... int_kpis__agg_mtd_cancelled_bookings.sql} | 0 ... int_kpis__agg_mtd_check_out_bookings.sql} | 0 ...pis__agg_mtd_completed_guest_journeys.sql} | 0 ...=> int_kpis__agg_mtd_created_bookings.sql} | 0 ..._kpis__agg_mtd_created_guest_journeys.sql} | 0 ...__agg_mtd_guest_journeys_with_payment.sql} | 0 ...l => int_kpis__agg_mtd_guest_payments.sql} | 0 ..._kpis__agg_mtd_started_guest_journeys.sql} | 0 models/intermediate/kpis/schema.yml | 36 +++++------ models/reporting/exposures.yml | 4 +- ...> monthly_agg_metrics_history_by_deal.sql} | 6 +- ...egated_metrics.sql => mtd_agg_metrics.sql} | 6 +- models/reporting/general/schema.yml | 8 +-- 28 files changed, 94 insertions(+), 94 deletions(-) rename models/intermediate/cross/{int_monthly_aggregated_metrics_history_by_deal.sql => int_monthly_agg_metrics_history_by_deal.sql} (91%) rename models/intermediate/cross/{int_mtd_aggregated_metrics.sql => int_mtd_agg_metrics.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_billable_bookings.sql => int_kpis__agg_monthly_billable_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_cancelled_bookings.sql => int_kpis__agg_monthly_cancelled_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_check_out_bookings.sql => int_kpis__agg_monthly_check_out_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_completed_guest_journeys.sql => int_kpis__agg_monthly_completed_guest_journeys.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_created_bookings.sql => int_kpis__agg_monthly_created_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_created_guest_journeys.sql => int_kpis__agg_monthly_created_guest_journeys.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_guest_journeys_with_payment.sql => int_kpis__agg_monthly_guest_journeys_with_payment.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_guest_payments.sql => int_kpis__agg_monthly_guest_payments.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_monthly_started_guest_journeys.sql => int_kpis__agg_monthly_started_guest_journeys.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_billable_bookings.sql => int_kpis__agg_mtd_billable_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_cancelled_bookings.sql => int_kpis__agg_mtd_cancelled_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_check_out_bookings.sql => int_kpis__agg_mtd_check_out_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_completed_guest_journeys.sql => int_kpis__agg_mtd_completed_guest_journeys.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_created_bookings.sql => int_kpis__agg_mtd_created_bookings.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_created_guest_journeys.sql => int_kpis__agg_mtd_created_guest_journeys.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_guest_journeys_with_payment.sql => int_kpis__agg_mtd_guest_journeys_with_payment.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_guest_payments.sql => int_kpis__agg_mtd_guest_payments.sql} (100%) rename models/intermediate/kpis/{int_kpis__aggregated_mtd_started_guest_journeys.sql => int_kpis__agg_mtd_started_guest_journeys.sql} (100%) rename models/reporting/general/{monthly_aggregated_metrics_history_by_deal.sql => monthly_agg_metrics_history_by_deal.sql} (95%) rename models/reporting/general/{mtd_aggregated_metrics.sql => mtd_agg_metrics.sql} (96%) diff --git a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql index 01c89a9..7bdbb48 100644 --- a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql +++ b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql @@ -1,9 +1,9 @@ {{ config(materialized="table", unique_key=["date", "id_deal"]) }} with - int_monthly_aggregated_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} + int_monthly_agg_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} ), - aggregated_metrics_by_deal_over_12_months as ( + agg_metrics_by_deal_over_12_months as ( select am.date, am.id_deal, @@ -28,7 +28,7 @@ with order by am.date rows between 12 preceding and 1 preceding ) as sum_listings_booked_in_month_preceding_12_months - from int_monthly_aggregated_metrics_history_by_deal am + from int_monthly_agg_metrics_history_by_deal am ), global_computation_over_12_months as ( select @@ -73,7 +73,7 @@ with ) over (partition by ambd.date) as avg_global_listings_booked_in_month_preceding_12_months - from aggregated_metrics_by_deal_over_12_months ambd + from agg_metrics_by_deal_over_12_months ambd ) select id_deal, diff --git a/models/intermediate/cross/int_monthly_aggregated_metrics_history_by_deal.sql b/models/intermediate/cross/int_monthly_agg_metrics_history_by_deal.sql similarity index 91% rename from models/intermediate/cross/int_monthly_aggregated_metrics_history_by_deal.sql rename to models/intermediate/cross/int_monthly_agg_metrics_history_by_deal.sql index 67d71f7..59b0a27 100644 --- a/models/intermediate/cross/int_monthly_aggregated_metrics_history_by_deal.sql +++ b/models/intermediate/cross/int_monthly_agg_metrics_history_by_deal.sql @@ -10,47 +10,47 @@ with ), created_bookings as ( select * - from {{ ref("int_kpis__aggregated_monthly_created_bookings") }} + from {{ ref("int_kpis__agg_monthly_created_bookings") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), check_out_bookings as ( select * - from {{ ref("int_kpis__aggregated_monthly_check_out_bookings") }} + from {{ ref("int_kpis__agg_monthly_check_out_bookings") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), cancelled_bookings as ( select * - from {{ ref("int_kpis__aggregated_monthly_cancelled_bookings") }} + from {{ ref("int_kpis__agg_monthly_cancelled_bookings") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), billable_bookings as ( select * - from {{ ref("int_kpis__aggregated_monthly_billable_bookings") }} + from {{ ref("int_kpis__agg_monthly_billable_bookings") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), created_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_monthly_created_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_created_guest_journeys") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), started_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_monthly_started_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_started_guest_journeys") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), completed_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_monthly_completed_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_completed_guest_journeys") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), guest_journeys_with_payment as ( select * - from {{ ref("int_kpis__aggregated_monthly_guest_journeys_with_payment") }} + from {{ ref("int_kpis__agg_monthly_guest_journeys_with_payment") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), guest_payments as ( select * - from {{ ref("int_kpis__aggregated_monthly_guest_payments") }} + from {{ ref("int_kpis__agg_monthly_guest_payments") }} where dimension in ('by_deal') and dimension_value <> 'UNSET' ), int_xero__monthly_invoicing_history_by_deal as ( diff --git a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql index d834a33..bba2d4f 100644 --- a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql +++ b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql @@ -1,7 +1,7 @@ {{ config(materialized="table", unique_key=["date", "id_deal"]) }} with - int_monthly_aggregated_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} + int_monthly_agg_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} ), int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }}), deal_history_from_previous_months as ( @@ -17,7 +17,7 @@ with coalesce(total_revenue_in_gbp, 0) as revenue_in_gbp, coalesce(created_bookings, 0) as created_bookings, coalesce(listings_booked_in_month, 0) as listings_booked_in_month - from int_monthly_aggregated_metrics_history_by_deal am + from int_monthly_agg_metrics_history_by_deal am -- Do not show data of ongoing month where am.date < date_trunc('month', current_date)::date ), @@ -71,7 +71,7 @@ with coalesce(sum(previous_twelve_months.revenue_in_gbp), 0), 0 ) as effective_deal_revenue_12_months_window from deal_history_from_previous_months as given_month - -- Retrieve aggregated data from same deal from the previous twelve + -- Retrieve agg data from same deal from the previous twelve -- months left join deal_history_from_previous_months as previous_twelve_months @@ -81,7 +81,7 @@ with and given_month.first_day_month >= previous_twelve_months.first_day_month + interval '1 months' group by 1, 2 - ) as aggregated_revenue_data_before_partition + ) as agg_revenue_data_before_partition ), metrics_attribution_to_given_month_per_deal as ( select @@ -100,10 +100,10 @@ with previous_2_month.first_day_month as previous_2_month_first_day_month, previous_12_month.first_day_month as previous_12_month_first_day_month, previous_13_month.first_day_month as previous_13_month_first_day_month, - aggregated_12m_window.from_first_day_month - as aggregated_revenue_from_first_day_month, - aggregated_12m_window.to_first_day_month - as aggregated_revenue_to_first_day_month, + agg_12m_window.from_first_day_month + as agg_revenue_from_first_day_month, + agg_12m_window.to_first_day_month + as agg_revenue_to_first_day_month, -- Revenue -- given_month.revenue_in_gbp as given_month_revenue_in_gbp, @@ -154,54 +154,54 @@ with -- 12 Months Window (Account Size) -- -- Bookings -- - aggregated_12m_window.deal_created_bookings_12_months_window, - aggregated_12m_window.global_created_bookings_12_months_window, + agg_12m_window.deal_created_bookings_12_months_window, + agg_12m_window.global_created_bookings_12_months_window, coalesce( cast( - aggregated_12m_window.deal_created_bookings_12_months_window + agg_12m_window.deal_created_bookings_12_months_window as decimal ) / nullif( - aggregated_12m_window.global_created_bookings_12_months_window, 0 + agg_12m_window.global_created_bookings_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_created_bookings, - aggregated_12m_window.deal_contribution_rank_to_global_created_bookings, + agg_12m_window.deal_contribution_rank_to_global_created_bookings, -- Listings -- round( - aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window, + agg_12m_window.deal_avg_listings_booked_in_month_12_months_window, 2 ) as deal_avg_listings_booked_in_month_12_months_window, round( - aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window, + agg_12m_window.global_avg_listings_booked_in_month_12_months_window, 2 ) as global_avg_listings_booked_in_month_12_months_window, coalesce( cast( - aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window + agg_12m_window.deal_avg_listings_booked_in_month_12_months_window as decimal ) / nullif( - aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window, + agg_12m_window.global_avg_listings_booked_in_month_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_avg_listings_booked_in_month, - aggregated_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month, + agg_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month, -- Revenue -- - aggregated_12m_window.deal_revenue_12_months_window, - aggregated_12m_window.effective_deal_revenue_12_months_window, - aggregated_12m_window.effective_global_revenue_12_months_window, + agg_12m_window.deal_revenue_12_months_window, + agg_12m_window.effective_deal_revenue_12_months_window, + agg_12m_window.effective_global_revenue_12_months_window, coalesce( cast( - aggregated_12m_window.effective_deal_revenue_12_months_window + agg_12m_window.effective_deal_revenue_12_months_window as decimal ) / nullif( - aggregated_12m_window.effective_global_revenue_12_months_window, 0 + agg_12m_window.effective_global_revenue_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_revenue, - aggregated_12m_window.deal_contribution_rank_to_global_revenue + agg_12m_window.deal_contribution_rank_to_global_revenue from deal_history_from_previous_months as given_month -- Retrieve monthly data from same deal and previous month @@ -232,9 +232,9 @@ with and previous_13_month.id_deal = given_month.id_deal -- Retrieve aggregation over 12 previous months left join - revenue_12_months_window_aggregation_per_deal aggregated_12m_window - on aggregated_12m_window.id_deal = given_month.id_deal - and aggregated_12m_window.first_day_month = given_month.first_day_month + revenue_12_months_window_aggregation_per_deal agg_12m_window + on agg_12m_window.id_deal = given_month.id_deal + and agg_12m_window.first_day_month = given_month.first_day_month ), growth_score_computation as ( select @@ -250,8 +250,8 @@ with m.previous_2_month_first_day_month, m.previous_12_month_first_day_month, m.previous_13_month_first_day_month, - m.aggregated_revenue_from_first_day_month, - m.aggregated_revenue_to_first_day_month, + m.agg_revenue_from_first_day_month, + m.agg_revenue_to_first_day_month, m.given_month_revenue_in_gbp, m.previous_1_month_revenue_in_gbp, @@ -358,8 +358,8 @@ select gsc.previous_2_month_first_day_month, gsc.previous_12_month_first_day_month, gsc.previous_13_month_first_day_month, - gsc.aggregated_revenue_from_first_day_month, - gsc.aggregated_revenue_to_first_day_month, + gsc.agg_revenue_from_first_day_month, + gsc.agg_revenue_to_first_day_month, gsc.given_month_revenue_in_gbp, gsc.previous_1_month_revenue_in_gbp, diff --git a/models/intermediate/cross/int_mtd_aggregated_metrics.sql b/models/intermediate/cross/int_mtd_agg_metrics.sql similarity index 100% rename from models/intermediate/cross/int_mtd_aggregated_metrics.sql rename to models/intermediate/cross/int_mtd_agg_metrics.sql diff --git a/models/intermediate/cross/int_mtd_vs_previous_year_metrics.sql b/models/intermediate/cross/int_mtd_vs_previous_year_metrics.sql index ef86616..9234fec 100644 --- a/models/intermediate/cross/int_mtd_vs_previous_year_metrics.sql +++ b/models/intermediate/cross/int_mtd_vs_previous_year_metrics.sql @@ -6,104 +6,104 @@ previous year for each line & computing relative increment. -- with created_bookings as ( select * - from {{ ref("int_kpis__aggregated_mtd_created_bookings") }} + from {{ ref("int_kpis__agg_mtd_created_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_created_bookings") }} + from {{ ref("int_kpis__agg_monthly_created_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), check_out_bookings as ( select * - from {{ ref("int_kpis__aggregated_mtd_check_out_bookings") }} + from {{ ref("int_kpis__agg_mtd_check_out_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_check_out_bookings") }} + from {{ ref("int_kpis__agg_monthly_check_out_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), cancelled_bookings as ( select * - from {{ ref("int_kpis__aggregated_mtd_cancelled_bookings") }} + from {{ ref("int_kpis__agg_mtd_cancelled_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_cancelled_bookings") }} + from {{ ref("int_kpis__agg_monthly_cancelled_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), billable_bookings as ( select * - from {{ ref("int_kpis__aggregated_mtd_billable_bookings") }} + from {{ ref("int_kpis__agg_mtd_billable_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_billable_bookings") }} + from {{ ref("int_kpis__agg_monthly_billable_bookings") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), created_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_mtd_created_guest_journeys") }} + from {{ ref("int_kpis__agg_mtd_created_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_created_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_created_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), started_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_mtd_started_guest_journeys") }} + from {{ ref("int_kpis__agg_mtd_started_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_started_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_started_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), completed_guest_journeys as ( select * - from {{ ref("int_kpis__aggregated_mtd_completed_guest_journeys") }} + from {{ ref("int_kpis__agg_mtd_completed_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_completed_guest_journeys") }} + from {{ ref("int_kpis__agg_monthly_completed_guest_journeys") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' ), guest_journeys_with_payment as ( select * - from {{ ref("int_kpis__aggregated_mtd_guest_journeys_with_payment") }} + from {{ ref("int_kpis__agg_mtd_guest_journeys_with_payment") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_guest_journeys_with_payment") }} + from {{ ref("int_kpis__agg_monthly_guest_journeys_with_payment") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' @@ -114,13 +114,13 @@ with int_mtd_deal_metrics as (select * from {{ ref("int_mtd_deal_metrics") }}), guest_payments as ( select * - from {{ ref("int_kpis__aggregated_mtd_guest_payments") }} + from {{ ref("int_kpis__agg_mtd_guest_payments") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' union all select * - from {{ ref("int_kpis__aggregated_monthly_guest_payments") }} + from {{ ref("int_kpis__agg_monthly_guest_payments") }} where dimension in ('global', 'by_number_of_listings', 'by_billing_country') and dimension_value <> 'UNSET' diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_billable_bookings.sql b/models/intermediate/kpis/int_kpis__agg_monthly_billable_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_billable_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_billable_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_cancelled_bookings.sql b/models/intermediate/kpis/int_kpis__agg_monthly_cancelled_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_cancelled_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_cancelled_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_check_out_bookings.sql b/models/intermediate/kpis/int_kpis__agg_monthly_check_out_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_check_out_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_check_out_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_completed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_monthly_completed_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_completed_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_completed_guest_journeys.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_created_bookings.sql b/models/intermediate/kpis/int_kpis__agg_monthly_created_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_created_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_created_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_created_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_monthly_created_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_created_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_created_guest_journeys.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_guest_journeys_with_payment.sql b/models/intermediate/kpis/int_kpis__agg_monthly_guest_journeys_with_payment.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_guest_journeys_with_payment.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_guest_journeys_with_payment.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_guest_payments.sql b/models/intermediate/kpis/int_kpis__agg_monthly_guest_payments.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_guest_payments.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_guest_payments.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_monthly_started_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_monthly_started_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_monthly_started_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_monthly_started_guest_journeys.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_billable_bookings.sql b/models/intermediate/kpis/int_kpis__agg_mtd_billable_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_billable_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_billable_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_cancelled_bookings.sql b/models/intermediate/kpis/int_kpis__agg_mtd_cancelled_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_cancelled_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_cancelled_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_check_out_bookings.sql b/models/intermediate/kpis/int_kpis__agg_mtd_check_out_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_check_out_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_check_out_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_completed_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_mtd_completed_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_completed_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_completed_guest_journeys.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_created_bookings.sql b/models/intermediate/kpis/int_kpis__agg_mtd_created_bookings.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_created_bookings.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_created_bookings.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_created_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_mtd_created_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_created_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_created_guest_journeys.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_guest_journeys_with_payment.sql b/models/intermediate/kpis/int_kpis__agg_mtd_guest_journeys_with_payment.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_guest_journeys_with_payment.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_guest_journeys_with_payment.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_guest_payments.sql b/models/intermediate/kpis/int_kpis__agg_mtd_guest_payments.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_guest_payments.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_guest_payments.sql diff --git a/models/intermediate/kpis/int_kpis__aggregated_mtd_started_guest_journeys.sql b/models/intermediate/kpis/int_kpis__agg_mtd_started_guest_journeys.sql similarity index 100% rename from models/intermediate/kpis/int_kpis__aggregated_mtd_started_guest_journeys.sql rename to models/intermediate/kpis/int_kpis__agg_mtd_started_guest_journeys.sql diff --git a/models/intermediate/kpis/schema.yml b/models/intermediate/kpis/schema.yml index d3399d8..7ec7876 100644 --- a/models/intermediate/kpis/schema.yml +++ b/models/intermediate/kpis/schema.yml @@ -445,7 +445,7 @@ models: Count of accumulated bookings created in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_created_bookings + - name: int_kpis__agg_monthly_created_bookings description: | This model computes the dimension aggregation for Monthly Created Bookings. @@ -499,7 +499,7 @@ models: data_type: bigint description: The monthly created bookings for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_created_bookings + - name: int_kpis__agg_mtd_created_bookings description: | This model computes the dimension aggregation for Month-To-Date Created Bookings. @@ -749,7 +749,7 @@ models: Count of accumulated guest journeys created in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_created_guest_journeys + - name: int_kpis__agg_monthly_created_guest_journeys description: | This model computes the dimension aggregation for Monthly Created Guest Journeys. @@ -802,7 +802,7 @@ models: data_type: bigint description: The monthtly created guest journeys for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_created_guest_journeys + - name: int_kpis__agg_mtd_created_guest_journeys description: | This model computes the dimension aggregation for Month-To-Date Created Guest Journeys. @@ -1051,7 +1051,7 @@ models: Count of accumulated guest journeys started in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_started_guest_journeys + - name: int_kpis__agg_monthly_started_guest_journeys description: | This model computes the dimension aggregation for Monthly Started Guest Journeys. @@ -1104,7 +1104,7 @@ models: data_type: bigint description: The monthly started guest journeys for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_started_guest_journeys + - name: int_kpis__agg_mtd_started_guest_journeys description: | This model computes the dimension aggregation for Month-To-Date Started Guest Journeys. @@ -1353,7 +1353,7 @@ models: Count of accumulated guest journeys completed in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_completed_guest_journeys + - name: int_kpis__agg_monthly_completed_guest_journeys description: | This model computes the dimension aggregation for Monthly Completed Guest Journeys. @@ -1406,7 +1406,7 @@ models: data_type: bigint description: The monthly completed guest journeys for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_completed_guest_journeys + - name: int_kpis__agg_mtd_completed_guest_journeys description: | This model computes the dimension aggregation for Month-To-Date Completed Guest Journeys. @@ -1655,7 +1655,7 @@ models: Count of accumulated guest journeys completed in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_guest_journeys_with_payment + - name: int_kpis__agg_monthly_guest_journeys_with_payment description: | This model computes the dimension aggregation for Monthly Guest Journeys with Payment. @@ -1708,7 +1708,7 @@ models: data_type: bigint description: The monthly guest journeys with payment for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_guest_journeys_with_payment + - name: int_kpis__agg_mtd_guest_journeys_with_payment description: | This model computes the dimension aggregation for Month-To-Date Guest Journeys with Payment. @@ -2012,7 +2012,7 @@ models: Sum of accumulated total payments paid by guests, without taxes, in GBP in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_guest_payments + - name: int_kpis__agg_monthly_guest_payments description: | This model computes the dimension aggregation for Monthly Guest Payments. @@ -2091,7 +2091,7 @@ models: The monthly total payments paid by guests, without taxes, in GBP for a given range date, dimension and value. - - name: int_kpis__aggregated_mtd_guest_payments + - name: int_kpis__agg_mtd_guest_payments description: | This model computes the dimension aggregation for Month-To-Date Guest Payments. @@ -2366,7 +2366,7 @@ models: Count of accumulated bookings checked-out in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_check_out_bookings + - name: int_kpis__agg_monthly_check_out_bookings description: | This model computes the dimension aggregation for Monthly Check-out Bookings. @@ -2419,7 +2419,7 @@ models: data_type: bigint description: The monthly checked-out bookings for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_check_out_bookings + - name: int_kpis__agg_mtd_check_out_bookings description: | This model computes the dimension aggregation for Month-To-Date Check-out Bookings. @@ -2668,7 +2668,7 @@ models: Count of accumulated bookings billable in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_billable_bookings + - name: int_kpis__agg_monthly_billable_bookings description: | This model computes the dimension aggregation for Monthly Billable Bookings. @@ -2721,7 +2721,7 @@ models: data_type: bigint description: The monthly billable bookings for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_billable_bookings + - name: int_kpis__agg_mtd_billable_bookings description: | This model computes the dimension aggregation for Month-To-Date Billable Bookings. @@ -2970,7 +2970,7 @@ models: Count of accumulated bookings cancelled in a given month up to the given date and per specified dimension. - - name: int_kpis__aggregated_monthly_cancelled_bookings + - name: int_kpis__agg_monthly_cancelled_bookings description: | This model computes the dimension aggregation for Monthly Cancelled Bookings. @@ -3023,7 +3023,7 @@ models: data_type: bigint description: The monthly cancelled bookings for a given date, dimension and value. - - name: int_kpis__aggregated_mtd_cancelled_bookings + - name: int_kpis__agg_mtd_cancelled_bookings description: | This model computes the dimension aggregation for Month-To-Date Cancelled Bookings. diff --git a/models/reporting/exposures.yml b/models/reporting/exposures.yml index 6bf660c..26970e7 100644 --- a/models/reporting/exposures.yml +++ b/models/reporting/exposures.yml @@ -113,8 +113,8 @@ exposures: Additionally, it allows to retrieve similar KPIs at Deal level. depends_on: - - ref('mtd_aggregated_metrics') - - ref('monthly_aggregated_metrics_history_by_deal') + - ref('mtd_agg_metrics') + - ref('monthly_agg_metrics_history_by_deal') owner: name: Oriol Roqué diff --git a/models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql b/models/reporting/general/monthly_agg_metrics_history_by_deal.sql similarity index 95% rename from models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql rename to models/reporting/general/monthly_agg_metrics_history_by_deal.sql index 0a5bb22..6922fc2 100644 --- a/models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql +++ b/models/reporting/general/monthly_agg_metrics_history_by_deal.sql @@ -1,6 +1,6 @@ with - int_monthly_aggregated_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} + int_monthly_agg_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} ) select @@ -113,4 +113,4 @@ select deposit_fees_in_gbp as deposit_fees_in_gbp, waiver_payments_in_gbp as waiver_payments_in_gbp, checkin_cover_fees_in_gbp as checkin_cover_fees_in_gbp -from int_monthly_aggregated_metrics_history_by_deal +from int_monthly_agg_metrics_history_by_deal diff --git a/models/reporting/general/mtd_aggregated_metrics.sql b/models/reporting/general/mtd_agg_metrics.sql similarity index 96% rename from models/reporting/general/mtd_aggregated_metrics.sql rename to models/reporting/general/mtd_agg_metrics.sql index d9c1aad..f3f9326 100644 --- a/models/reporting/general/mtd_aggregated_metrics.sql +++ b/models/reporting/general/mtd_agg_metrics.sql @@ -11,9 +11,9 @@ with {% endif %} {% endfor %} ), - int_mtd_aggregated_metrics as ( + int_mtd_agg_metrics as ( select m.*, d.dimension_display - from {{ ref("int_mtd_aggregated_metrics") }} m + from {{ ref("int_mtd_agg_metrics") }} m -- The following clause limits the display execution -- to only include those dimensions configured to -- appear for production purposes @@ -38,7 +38,7 @@ select previous_year_value as previous_year_value, relative_increment as relative_increment, relative_increment_with_sign_format as relative_increment_with_sign_format -from int_mtd_aggregated_metrics +from int_mtd_agg_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 diff --git a/models/reporting/general/schema.yml b/models/reporting/general/schema.yml index 92cee23..525429d 100644 --- a/models/reporting/general/schema.yml +++ b/models/reporting/general/schema.yml @@ -307,7 +307,7 @@ models: tests: - not_null - - name: mtd_aggregated_metrics + - name: mtd_agg_metrics description: | This model aggregates the historic information of our business by providing different metrics computed at global and dimension level. @@ -447,19 +447,19 @@ models: positive impact for Superhog, otherwise is equal to relative_increment. This value is specially created for formatting in PBI - - name: monthly_aggregated_metrics_history_by_deal + - name: monthly_agg_metrics_history_by_deal description: | 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` model which contain the raw metrics data per source. This table is used to provide "By Deal" metrics in the Business Overview reporting. - Unlike the mtd_aggregated_metrics, this model does not abstract each metric, since + Unlike the mtd_agg_metrics, this model does not abstract each metric, since no comparison versus last year is performed. In short, it just gathers the information stored in the abovementioned models. To keep in mind: aggregating the information of this model will not necessarily result into - the int_mtd_aggregated metrics because 1) the mtd version contains more computing dates + the int_mtd_agg_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 enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is not necessarily the case. From 5bcfd7cb9c6b16537813da42416c47e2f1aa3d7e Mon Sep 17 00:00:00 2001 From: Joaquin Date: Tue, 5 Nov 2024 12:37:31 +0100 Subject: [PATCH 2/4] Revert cross models --- .../cross/int_monthly_12m_window_contribution_by_deal.sql | 6 +++--- ...=> int_monthly_aggregated_metrics_history_by_deal.sql} | 0 .../cross/int_monthly_growth_score_by_deal.sql | 6 +++--- ...mtd_agg_metrics.sql => int_mtd_aggregated_metrics.sql} | 0 models/reporting/exposures.yml | 4 ++-- ...sql => monthly_aggregated_metrics_history_by_deal.sql} | 6 +++--- .../{mtd_agg_metrics.sql => mtd_aggregated_metrics.sql} | 6 +++--- models/reporting/general/schema.yml | 8 ++++---- 8 files changed, 18 insertions(+), 18 deletions(-) rename models/intermediate/cross/{int_monthly_agg_metrics_history_by_deal.sql => int_monthly_aggregated_metrics_history_by_deal.sql} (100%) rename models/intermediate/cross/{int_mtd_agg_metrics.sql => int_mtd_aggregated_metrics.sql} (100%) rename models/reporting/general/{monthly_agg_metrics_history_by_deal.sql => monthly_aggregated_metrics_history_by_deal.sql} (95%) rename models/reporting/general/{mtd_agg_metrics.sql => mtd_aggregated_metrics.sql} (96%) diff --git a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql index 7bdbb48..bce0b21 100644 --- a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql +++ b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql @@ -1,7 +1,7 @@ {{ config(materialized="table", unique_key=["date", "id_deal"]) }} with - int_monthly_agg_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} + int_monthly_aggregated_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} ), agg_metrics_by_deal_over_12_months as ( select @@ -28,7 +28,7 @@ with order by am.date rows between 12 preceding and 1 preceding ) 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 ( select diff --git a/models/intermediate/cross/int_monthly_agg_metrics_history_by_deal.sql b/models/intermediate/cross/int_monthly_aggregated_metrics_history_by_deal.sql similarity index 100% rename from models/intermediate/cross/int_monthly_agg_metrics_history_by_deal.sql rename to models/intermediate/cross/int_monthly_aggregated_metrics_history_by_deal.sql diff --git a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql index bba2d4f..9941236 100644 --- a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql +++ b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql @@ -1,7 +1,7 @@ {{ config(materialized="table", unique_key=["date", "id_deal"]) }} with - int_monthly_agg_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} + int_monthly_aggregated_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} ), int_hubspot__deal as (select * from {{ ref("int_hubspot__deal") }}), deal_history_from_previous_months as ( @@ -17,7 +17,7 @@ with coalesce(total_revenue_in_gbp, 0) as revenue_in_gbp, coalesce(created_bookings, 0) as created_bookings, 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 where am.date < date_trunc('month', current_date)::date ), diff --git a/models/intermediate/cross/int_mtd_agg_metrics.sql b/models/intermediate/cross/int_mtd_aggregated_metrics.sql similarity index 100% rename from models/intermediate/cross/int_mtd_agg_metrics.sql rename to models/intermediate/cross/int_mtd_aggregated_metrics.sql diff --git a/models/reporting/exposures.yml b/models/reporting/exposures.yml index 26970e7..6bf660c 100644 --- a/models/reporting/exposures.yml +++ b/models/reporting/exposures.yml @@ -113,8 +113,8 @@ exposures: Additionally, it allows to retrieve similar KPIs at Deal level. depends_on: - - ref('mtd_agg_metrics') - - ref('monthly_agg_metrics_history_by_deal') + - ref('mtd_aggregated_metrics') + - ref('monthly_aggregated_metrics_history_by_deal') owner: name: Oriol Roqué diff --git a/models/reporting/general/monthly_agg_metrics_history_by_deal.sql b/models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql similarity index 95% rename from models/reporting/general/monthly_agg_metrics_history_by_deal.sql rename to models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql index 6922fc2..0a5bb22 100644 --- a/models/reporting/general/monthly_agg_metrics_history_by_deal.sql +++ b/models/reporting/general/monthly_aggregated_metrics_history_by_deal.sql @@ -1,6 +1,6 @@ with - int_monthly_agg_metrics_history_by_deal as ( - select * from {{ ref("int_monthly_agg_metrics_history_by_deal") }} + int_monthly_aggregated_metrics_history_by_deal as ( + select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} ) select @@ -113,4 +113,4 @@ select deposit_fees_in_gbp as deposit_fees_in_gbp, waiver_payments_in_gbp as waiver_payments_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 diff --git a/models/reporting/general/mtd_agg_metrics.sql b/models/reporting/general/mtd_aggregated_metrics.sql similarity index 96% rename from models/reporting/general/mtd_agg_metrics.sql rename to models/reporting/general/mtd_aggregated_metrics.sql index f3f9326..d9c1aad 100644 --- a/models/reporting/general/mtd_agg_metrics.sql +++ b/models/reporting/general/mtd_aggregated_metrics.sql @@ -11,9 +11,9 @@ with {% endif %} {% endfor %} ), - int_mtd_agg_metrics as ( + int_mtd_aggregated_metrics as ( 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 -- to only include those dimensions configured to -- appear for production purposes @@ -38,7 +38,7 @@ select previous_year_value as previous_year_value, relative_increment as relative_increment, 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 in the MTD for the current month and the previous month. The main reason is diff --git a/models/reporting/general/schema.yml b/models/reporting/general/schema.yml index 525429d..21a6518 100644 --- a/models/reporting/general/schema.yml +++ b/models/reporting/general/schema.yml @@ -307,7 +307,7 @@ models: tests: - not_null - - name: mtd_agg_metrics + - name: mtd_aggregated_metrics description: | This model aggregates the historic information of our business by providing different metrics computed at global and dimension level. @@ -447,19 +447,19 @@ models: positive impact for Superhog, otherwise is equal to relative_increment. This value is specially created for formatting in PBI - - name: monthly_agg_metrics_history_by_deal + - name: monthly_aggregated_metrics_history_by_deal description: | 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` model which contain the raw metrics data per source. 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 in the abovementioned models. 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 enforces that a booking/guest journey/listing/etc has a host with a deal assigned, which is not necessarily the case. From abd4a4e8f2d853ac26dbd6a491f66098967a0ee1 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Tue, 5 Nov 2024 12:49:50 +0100 Subject: [PATCH 3/4] fixed int_monthly_growth_score_by_deal --- .../int_monthly_growth_score_by_deal.sql | 58 +++++++++---------- 1 file changed, 29 insertions(+), 29 deletions(-) diff --git a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql index 9941236..d834a33 100644 --- a/models/intermediate/cross/int_monthly_growth_score_by_deal.sql +++ b/models/intermediate/cross/int_monthly_growth_score_by_deal.sql @@ -71,7 +71,7 @@ with coalesce(sum(previous_twelve_months.revenue_in_gbp), 0), 0 ) as effective_deal_revenue_12_months_window from deal_history_from_previous_months as given_month - -- Retrieve agg data from same deal from the previous twelve + -- Retrieve aggregated data from same deal from the previous twelve -- months left join deal_history_from_previous_months as previous_twelve_months @@ -81,7 +81,7 @@ with and given_month.first_day_month >= previous_twelve_months.first_day_month + interval '1 months' group by 1, 2 - ) as agg_revenue_data_before_partition + ) as aggregated_revenue_data_before_partition ), metrics_attribution_to_given_month_per_deal as ( select @@ -100,10 +100,10 @@ with previous_2_month.first_day_month as previous_2_month_first_day_month, previous_12_month.first_day_month as previous_12_month_first_day_month, previous_13_month.first_day_month as previous_13_month_first_day_month, - agg_12m_window.from_first_day_month - as agg_revenue_from_first_day_month, - agg_12m_window.to_first_day_month - as agg_revenue_to_first_day_month, + aggregated_12m_window.from_first_day_month + as aggregated_revenue_from_first_day_month, + aggregated_12m_window.to_first_day_month + as aggregated_revenue_to_first_day_month, -- Revenue -- given_month.revenue_in_gbp as given_month_revenue_in_gbp, @@ -154,54 +154,54 @@ with -- 12 Months Window (Account Size) -- -- Bookings -- - agg_12m_window.deal_created_bookings_12_months_window, - agg_12m_window.global_created_bookings_12_months_window, + aggregated_12m_window.deal_created_bookings_12_months_window, + aggregated_12m_window.global_created_bookings_12_months_window, coalesce( cast( - agg_12m_window.deal_created_bookings_12_months_window + aggregated_12m_window.deal_created_bookings_12_months_window as decimal ) / nullif( - agg_12m_window.global_created_bookings_12_months_window, 0 + aggregated_12m_window.global_created_bookings_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_created_bookings, - agg_12m_window.deal_contribution_rank_to_global_created_bookings, + aggregated_12m_window.deal_contribution_rank_to_global_created_bookings, -- Listings -- round( - agg_12m_window.deal_avg_listings_booked_in_month_12_months_window, + aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window, 2 ) as deal_avg_listings_booked_in_month_12_months_window, round( - agg_12m_window.global_avg_listings_booked_in_month_12_months_window, + aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window, 2 ) as global_avg_listings_booked_in_month_12_months_window, coalesce( cast( - agg_12m_window.deal_avg_listings_booked_in_month_12_months_window + aggregated_12m_window.deal_avg_listings_booked_in_month_12_months_window as decimal ) / nullif( - agg_12m_window.global_avg_listings_booked_in_month_12_months_window, + aggregated_12m_window.global_avg_listings_booked_in_month_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_avg_listings_booked_in_month, - agg_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month, + aggregated_12m_window.deal_contribution_rank_to_global_avg_listings_booked_in_month, -- Revenue -- - agg_12m_window.deal_revenue_12_months_window, - agg_12m_window.effective_deal_revenue_12_months_window, - agg_12m_window.effective_global_revenue_12_months_window, + aggregated_12m_window.deal_revenue_12_months_window, + aggregated_12m_window.effective_deal_revenue_12_months_window, + aggregated_12m_window.effective_global_revenue_12_months_window, coalesce( cast( - agg_12m_window.effective_deal_revenue_12_months_window + aggregated_12m_window.effective_deal_revenue_12_months_window as decimal ) / nullif( - agg_12m_window.effective_global_revenue_12_months_window, 0 + aggregated_12m_window.effective_global_revenue_12_months_window, 0 ), 0 ) as deal_contribution_share_to_global_revenue, - agg_12m_window.deal_contribution_rank_to_global_revenue + aggregated_12m_window.deal_contribution_rank_to_global_revenue from deal_history_from_previous_months as given_month -- Retrieve monthly data from same deal and previous month @@ -232,9 +232,9 @@ with and previous_13_month.id_deal = given_month.id_deal -- Retrieve aggregation over 12 previous months left join - revenue_12_months_window_aggregation_per_deal agg_12m_window - on agg_12m_window.id_deal = given_month.id_deal - and agg_12m_window.first_day_month = given_month.first_day_month + revenue_12_months_window_aggregation_per_deal aggregated_12m_window + on aggregated_12m_window.id_deal = given_month.id_deal + and aggregated_12m_window.first_day_month = given_month.first_day_month ), growth_score_computation as ( select @@ -250,8 +250,8 @@ with m.previous_2_month_first_day_month, m.previous_12_month_first_day_month, m.previous_13_month_first_day_month, - m.agg_revenue_from_first_day_month, - m.agg_revenue_to_first_day_month, + m.aggregated_revenue_from_first_day_month, + m.aggregated_revenue_to_first_day_month, m.given_month_revenue_in_gbp, m.previous_1_month_revenue_in_gbp, @@ -358,8 +358,8 @@ select gsc.previous_2_month_first_day_month, gsc.previous_12_month_first_day_month, gsc.previous_13_month_first_day_month, - gsc.agg_revenue_from_first_day_month, - gsc.agg_revenue_to_first_day_month, + gsc.aggregated_revenue_from_first_day_month, + gsc.aggregated_revenue_to_first_day_month, gsc.given_month_revenue_in_gbp, gsc.previous_1_month_revenue_in_gbp, From d76b8ac205412355dd734e146194b9b2eab984d2 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Tue, 5 Nov 2024 12:53:27 +0100 Subject: [PATCH 4/4] fixed int_monthly_12m_window_contribution_by_deal --- .../cross/int_monthly_12m_window_contribution_by_deal.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql index bce0b21..01c89a9 100644 --- a/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql +++ b/models/intermediate/cross/int_monthly_12m_window_contribution_by_deal.sql @@ -3,7 +3,7 @@ with int_monthly_aggregated_metrics_history_by_deal as ( select * from {{ ref("int_monthly_aggregated_metrics_history_by_deal") }} ), - agg_metrics_by_deal_over_12_months as ( + aggregated_metrics_by_deal_over_12_months as ( select am.date, am.id_deal, @@ -73,7 +73,7 @@ with ) over (partition by ambd.date) as avg_global_listings_booked_in_month_preceding_12_months - from agg_metrics_by_deal_over_12_months ambd + from aggregated_metrics_by_deal_over_12_months ambd ) select id_deal,