From fb2b2def52d9a95a9baea9c73533ac8fc6243e57 Mon Sep 17 00:00:00 2001 From: Joaquin Date: Mon, 31 Mar 2025 14:53:20 +0200 Subject: [PATCH] New created bookings with services model --- ...ew_dash_created_bookings_with_services.sql | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_bookings_with_services.sql diff --git a/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_bookings_with_services.sql b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_bookings_with_services.sql new file mode 100644 index 0000000..cb86f98 --- /dev/null +++ b/models/intermediate/kpis/int_kpis__metric_daily_new_dash_created_bookings_with_services.sql @@ -0,0 +1,36 @@ +{{ + config( + materialized="table", + unique_key=["id_booking", "service_name", "date", "service_business_type"], + ) +}} +select + -- Unique Key -- + icbs.id_booking, + date(icbs.booking_created_date_utc) as date, + coalesce(icbsd.service_name) as service_name, + coalesce(icbsd.service_business_type, 'UNSET') as service_business_type, + -- Dimensions -- + coalesce(icbs.id_deal, 'UNSET') as id_deal, + case when icbsd.is_upgraded_service then 'YES' else 'NO' end as is_upgraded_service, + coalesce(icbs.new_dash_version, 'UNSET') as new_dash_version, + coalesce( + icd.main_billing_country_iso_3_per_deal, 'UNSET' + ) as main_billing_country_iso_3_per_deal, + coalesce( + icmas.active_accommodations_per_deal_segmentation, 'UNSET' + ) as active_accommodations_per_deal_segmentation +from {{ ref("int_core__booking_summary") }} as icbs +inner join + {{ ref("int_core__booking_service_detail") }} as icbsd + on icbs.id_booking = icbsd.id_booking +left join {{ ref("int_core__deal") }} as icd on icbs.id_deal = icd.id_deal +left join + {{ ref("int_kpis__dimension_daily_accommodation") }} as icmas + on icbs.id_deal = icmas.id_deal + and date(icbsd.service_detail_created_at_utc) = icmas.date +where + icbs.is_user_in_new_dash = true + and icbs.is_missing_id_deal = false + and icbsd.service_detail_created_at_utc + >= icbs.user_in_new_dash_since_timestamp_at_utc