Merged PR 3523: First version of BookingView and BookingViewToService integration
# Description Modelises 2 new tables into staging: * BookingView * BookingViewToService Ideally, we need the contents of BookingToService. This does not exist, so we will need to modelise it in intermediate. Current relationship is that 1) we know services applied to a booking view id (BookingViewToService ) 2) we know booking view id how it relates to booking (BookingView) 3) we can retrieve booking info as usual (Booking, etc) # 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: #23996
This commit is contained in:
parent
0af8949f67
commit
c21040fa30
4 changed files with 171 additions and 0 deletions
|
|
@ -253,3 +253,7 @@ sources:
|
|||
identifier: ProtectionPlanToPrice
|
||||
- name: ProtectionPlanToCurrency
|
||||
identifier: ProtectionPlanToCurrency
|
||||
- name: BookingView
|
||||
identifier: BookingView
|
||||
- name: BookingViewToService
|
||||
identifier: BookingViewToService
|
||||
|
|
|
|||
|
|
@ -963,3 +963,115 @@ models:
|
|||
Timestamp of when this data was extracted into DWH.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: stg_core__booking_view
|
||||
description: |
|
||||
Current usage only to retrieve the relationship of Booking Id <-> Booking View Id
|
||||
for booking_view_to_service.
|
||||
|
||||
columns:
|
||||
- name: id_booking_view
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the booking view. Acts as the primary key for this table.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- name: id_booking
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the booking. Acts as foreign key for the Booking table.
|
||||
tests:
|
||||
- not_null
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this Booking View record was created.
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this Booking View record was last updated.
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this data was extracted into DWH.
|
||||
|
||||
- name: stg_core__booking_view_to_service
|
||||
description: |
|
||||
Provides the information of which services within New Dashboard initiative
|
||||
are applied to a certain booking view. Needs to be joined with booking view
|
||||
in order to retrieve the booking id and from there more interesting attributes.
|
||||
Contains both product services as well as protection services.
|
||||
|
||||
columns:
|
||||
- name: id_booking_view_to_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the booking view to service. Acts as the primary key for this table.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
- name: id_booking_view
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the booking view. Acts as the foreign key for the Booking View table.
|
||||
tests:
|
||||
- not_null
|
||||
- name: id_verification
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the verification. Can be null.
|
||||
- name: id_product_service
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the product service. Can be null.
|
||||
- name: id_protection_plan
|
||||
data_type: integer
|
||||
description: |
|
||||
Identifier of the protection plan. Can be null.
|
||||
- name: service_name
|
||||
data_type: string
|
||||
description: |
|
||||
Name of the service that applies to a certain Booking View.
|
||||
tests:
|
||||
- not_null
|
||||
- name: service_protection_amount
|
||||
data_type: string
|
||||
description: |
|
||||
Amount protected, as a range. This amount can change depending on
|
||||
the applied service and the result of the service status.
|
||||
tests:
|
||||
- not_null
|
||||
- name: service_status
|
||||
data_type: string
|
||||
description: |
|
||||
Status of the applied service on the Booking View.
|
||||
tests:
|
||||
- not_null
|
||||
- accepted_values:
|
||||
values:
|
||||
- "NOFLAGS"
|
||||
- "REJECTED"
|
||||
- "FLAGGED"
|
||||
- "NOCHECKS"
|
||||
- "-"
|
||||
- name: created_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this Booking View To Service record was created.
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: |
|
||||
Date of when this Booking View To Service record was created.
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this Booking View To Service record was last updated.
|
||||
- name: updated_date_utc
|
||||
data_type: Date
|
||||
description: |
|
||||
Date of when this Booking View To Service record was last updated.
|
||||
- name: dwh_extracted_at_utc
|
||||
data_type: timestamp
|
||||
description: |
|
||||
Timestamp of when this data was extracted into DWH.
|
||||
|
|
|
|||
22
models/staging/core/stg_core__booking_view.sql
Normal file
22
models/staging/core/stg_core__booking_view.sql
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
{{ config(materialized="incremental", unique_key="id_booking_view") }}
|
||||
with
|
||||
raw_booking_view as (select * from {{ source("core", "BookingView") }}),
|
||||
stg_core__booking_view as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_booking_view,
|
||||
{{ adapter.quote("BookingId") }} as id_booking,
|
||||
|
||||
{{ adapter.quote("CreatedDate") }} as created_at_utc,
|
||||
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
||||
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_booking_view
|
||||
)
|
||||
select *
|
||||
from stg_core__booking_view
|
||||
{% if is_incremental() %}
|
||||
where
|
||||
updated_at_utc
|
||||
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
|
||||
{% endif %}
|
||||
33
models/staging/core/stg_core__booking_view_to_service.sql
Normal file
33
models/staging/core/stg_core__booking_view_to_service.sql
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
{{ config(materialized="incremental", unique_key="id_booking_view_to_service") }}
|
||||
with
|
||||
raw_booking_view_to_service as (
|
||||
select * from {{ source("core", "BookingViewToService") }}
|
||||
),
|
||||
stg_core__booking_view_to_service as (
|
||||
select
|
||||
{{ adapter.quote("Id") }} as id_booking_view_to_service,
|
||||
{{ adapter.quote("BookingViewId") }} as id_booking_view,
|
||||
{{ adapter.quote("VerificationId") }} as id_verification,
|
||||
{{ adapter.quote("ProductServiceId") }} as id_product_service,
|
||||
{{ adapter.quote("ProtectionPlanId") }} as id_protection_plan,
|
||||
|
||||
{{ adapter.quote("ServiceName") }} as service_name,
|
||||
{{ adapter.quote("ProtectionAmount") }} as service_protection_amount,
|
||||
upper({{ adapter.quote("Status") }}) as service_status,
|
||||
|
||||
{{ adapter.quote("CreatedDate") }} as created_at_utc,
|
||||
cast({{ adapter.quote("CreatedDate") }} as date) as created_date_utc,
|
||||
{{ adapter.quote("UpdatedDate") }} as updated_at_utc,
|
||||
cast({{ adapter.quote("UpdatedDate") }} as date) as updated_date_utc,
|
||||
|
||||
{{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc
|
||||
|
||||
from raw_booking_view_to_service
|
||||
)
|
||||
select *
|
||||
from stg_core__booking_view_to_service
|
||||
{% if is_incremental() %}
|
||||
where
|
||||
updated_at_utc
|
||||
>= ((select max(updated_at_utc) from {{ this }}) - interval '7 days')
|
||||
{% endif %}
|
||||
Loading…
Add table
Add a link
Reference in a new issue