Merged PR 3646: Adding informative fields in booking tables for New Pricing
# Description Adds informative fields to New Pricing booking-related tables. These are added into booking_to_service which is a view, and propagated and materialised as table in the `booking_service_detail` and `booking_summary`. The new fields are: - Date versions for relevant booking timestamps (Created, Updated, Check-in, Check-out) - Booking Number of nights - Ids for the Accommodation and UserProductBundle - Program Name (aka Product Bundle Name). I dislike the fact that it's named "Product" because you can have Protection Plans in the Program as well... so I opted for a more conventional business-oriented naming, which is Program. Added a bunch of tests + documentation. # 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: #20809
This commit is contained in:
parent
059c92b345
commit
28114d645e
4 changed files with 170 additions and 2 deletions
|
|
@ -53,6 +53,7 @@ with
|
|||
'PRODUCT' as service_source,
|
||||
bts.service_status,
|
||||
bts.booking_status,
|
||||
bts.program_name,
|
||||
ps.product_service_display_name as service_name,
|
||||
pstp.payment_type,
|
||||
pstp.price_base_unit,
|
||||
|
|
@ -94,6 +95,7 @@ with
|
|||
'PROTECTION' as service_source,
|
||||
bts.service_status,
|
||||
bts.booking_status,
|
||||
bts.program_name,
|
||||
pp.protection_display_name as service_name,
|
||||
pptp.payment_type,
|
||||
pptp.price_base_unit,
|
||||
|
|
@ -135,6 +137,7 @@ with
|
|||
'UNKNOWN' as service_source,
|
||||
bts.service_status,
|
||||
bts.booking_status,
|
||||
bts.program_name,
|
||||
bts.service_name,
|
||||
'UNKNOWN' as payment_type,
|
||||
'UNKNOWN' as price_base_unit,
|
||||
|
|
@ -177,6 +180,7 @@ select
|
|||
service_source,
|
||||
service_status,
|
||||
booking_status,
|
||||
program_name,
|
||||
service_name,
|
||||
payment_type,
|
||||
price_base_unit,
|
||||
|
|
|
|||
|
|
@ -10,14 +10,22 @@ with
|
|||
select
|
||||
bts.id_booking,
|
||||
bts.id_verification_request,
|
||||
bts.id_accommodation,
|
||||
bts.id_user_product_bundle,
|
||||
bts.id_deal,
|
||||
bts.id_user_host,
|
||||
bts.id_user_guest,
|
||||
bts.booking_status,
|
||||
bts.program_name,
|
||||
bts.booking_created_at_utc,
|
||||
bts.booking_created_date_utc,
|
||||
bts.booking_updated_at_utc,
|
||||
bts.booking_updated_date_utc,
|
||||
bts.booking_check_in_at_utc,
|
||||
bts.booking_check_in_date_utc,
|
||||
bts.booking_check_out_at_utc,
|
||||
bts.booking_check_out_date_utc,
|
||||
bts.booking_number_of_nights,
|
||||
bts.host_currency_code,
|
||||
bts.is_user_in_new_dash,
|
||||
bts.new_dash_version,
|
||||
|
|
@ -101,14 +109,22 @@ inner join
|
|||
group by
|
||||
bts.id_booking,
|
||||
bts.id_verification_request,
|
||||
bts.id_accommodation,
|
||||
bts.id_user_product_bundle,
|
||||
bts.id_deal,
|
||||
bts.id_user_host,
|
||||
bts.id_user_guest,
|
||||
bts.booking_status,
|
||||
bts.program_name,
|
||||
bts.booking_created_at_utc,
|
||||
bts.booking_created_date_utc,
|
||||
bts.booking_updated_at_utc,
|
||||
bts.booking_updated_date_utc,
|
||||
bts.booking_check_in_at_utc,
|
||||
bts.booking_check_in_date_utc,
|
||||
bts.booking_check_out_at_utc,
|
||||
bts.booking_check_out_date_utc,
|
||||
bts.booking_number_of_nights,
|
||||
bts.host_currency_code,
|
||||
bts.is_missing_id_deal,
|
||||
bts.is_user_in_new_dash,
|
||||
|
|
|
|||
|
|
@ -6,10 +6,18 @@ with
|
|||
stg_core__booking_view as (select * from {{ ref("stg_core__booking_view") }}),
|
||||
stg_core__booking as (select * from {{ ref("stg_core__booking") }}),
|
||||
stg_core__booking_state as (select * from {{ ref("stg_core__booking_state") }}),
|
||||
stg_core__booking_to_product_bundle as (
|
||||
select * from {{ ref("stg_core__booking_to_product_bundle") }}
|
||||
),
|
||||
stg_core__user_product_bundle as (
|
||||
select * from {{ ref("stg_core__user_product_bundle") }}
|
||||
),
|
||||
int_core__user_host as (select * from {{ ref("int_core__user_host") }})
|
||||
select
|
||||
bv.id_booking,
|
||||
b.id_verification_request,
|
||||
b.id_accommodation,
|
||||
btpb.id_user_product_bundle,
|
||||
bvts.id_booking_view_to_service as id_booking_service_detail,
|
||||
bvts.id_verification,
|
||||
bvts.id_product_service,
|
||||
|
|
@ -17,6 +25,7 @@ select
|
|||
uh.id_deal,
|
||||
b.id_user_host,
|
||||
b.id_user_guest,
|
||||
upb.product_bundle_display_name as program_name,
|
||||
bvts.service_name,
|
||||
bvts.service_status,
|
||||
upper(bs.booking_state) as booking_status,
|
||||
|
|
@ -24,9 +33,14 @@ select
|
|||
bvts.created_at_utc as service_detail_created_at_utc,
|
||||
bvts.updated_at_utc as service_detail_updated_at_utc,
|
||||
b.created_at_utc as booking_created_at_utc,
|
||||
b.created_date_utc as booking_created_date_utc,
|
||||
b.updated_at_utc as booking_updated_at_utc,
|
||||
b.updated_date_utc as booking_updated_date_utc,
|
||||
b.check_in_at_utc as booking_check_in_at_utc,
|
||||
b.check_in_date_utc as booking_check_in_date_utc,
|
||||
b.check_out_at_utc as booking_check_out_at_utc,
|
||||
b.check_out_date_utc as booking_check_out_date_utc,
|
||||
b.check_out_date_utc - b.check_in_date_utc as booking_number_of_nights,
|
||||
uh.account_currency_iso4217 as host_currency_code,
|
||||
uh.is_missing_id_deal,
|
||||
uh.is_user_in_new_dash,
|
||||
|
|
@ -45,3 +59,10 @@ inner join stg_core__booking_view bv on bvts.id_booking_view = bv.id_booking_vie
|
|||
left join stg_core__booking b on bv.id_booking = b.id_booking
|
||||
left join stg_core__booking_state bs on b.id_booking_state = bs.id_booking_state
|
||||
left join int_core__user_host uh on b.id_user_host = uh.id_user_host
|
||||
left join
|
||||
stg_core__booking_to_product_bundle btpb
|
||||
on b.id_booking = btpb.id_booking
|
||||
and btpb.has_no_end_date
|
||||
left join
|
||||
stg_core__user_product_bundle upb
|
||||
on btpb.id_user_product_bundle = upb.id_user_product_bundle
|
||||
|
|
|
|||
|
|
@ -3223,6 +3223,23 @@ models:
|
|||
The identifier of the verification request. It acts as Foreign Key to
|
||||
Verification Request table. It can be null.
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: bigint
|
||||
description:
|
||||
The identifier of the accommodation or listing. It acts as Foreign Key
|
||||
to the Accommodation table. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_user_product_bundle
|
||||
data_type: bigint
|
||||
description:
|
||||
The identifier of the Product Bundle, or program, that a User has applied
|
||||
to the Booking. It acts as Foreign Key to the User Product Bundle table.
|
||||
It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_verification
|
||||
data_type: bigint
|
||||
description: |
|
||||
|
|
@ -3259,6 +3276,14 @@ models:
|
|||
Unique identifier of the user that acts as a Guest.
|
||||
Can be null if Superhog does not interact with the Guest.
|
||||
|
||||
- name: program_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the program, or product bundle, applied to the booking.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -3309,6 +3334,13 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when the Booking record was created in the Backend.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3316,6 +3348,13 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when the Booking record was last updated in the Backend.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_in_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3323,6 +3362,13 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_in_date_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Date of the Check-in of the Booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_out_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3330,6 +3376,18 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_out_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of the Check-out of the Booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_number_of_nights
|
||||
data_type: integer
|
||||
description: |
|
||||
Number of nights between Check-in date and Check-out date.
|
||||
|
||||
- name: host_currency_code
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -3511,6 +3569,14 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: program_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the program, or product bundle, applied to the booking.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -3691,6 +3757,23 @@ models:
|
|||
The identifier of the verification request. It acts as Foreign Key to
|
||||
Verification Request table. It can be null.
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: bigint
|
||||
description:
|
||||
The identifier of the accommodation or listing. It acts as Foreign Key
|
||||
to the Accommodation table. It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_user_product_bundle
|
||||
data_type: bigint
|
||||
description:
|
||||
The identifier of the Product Bundle, or program, that a User has applied
|
||||
to the Booking. It acts as Foreign Key to the User Product Bundle table.
|
||||
It cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_deal
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
@ -3716,6 +3799,14 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: program_name
|
||||
data_type: string
|
||||
description: |
|
||||
The name of the program, or product bundle, applied to the booking.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3724,6 +3815,14 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when the Booking record was created in the Backend.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3732,6 +3831,14 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_updated_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when the Booking record was last updated in the Backend.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_in_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
|
|
@ -3740,14 +3847,34 @@ models:
|
|||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_out_at_utc
|
||||
- name: booking_check_in_date_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of the Check-out of the Booking.
|
||||
Date of the Check-in of the Booking.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_out_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of the Check-out of the Booking.
|
||||
Cannot be null.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_check_out_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of the Check-out of the Booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: booking_number_of_nights
|
||||
data_type: integer
|
||||
description: |
|
||||
Number of nights between Check-in date and Check-out date.
|
||||
|
||||
- name: host_currency_code
|
||||
data_type: string
|
||||
description: |
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue