Merged PR 3814: staging model check in hero
# Description Staging model for Check-ins from CIH API # 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. - [ ] I've picked the right materialization for the affected models. # Other - [ ] Check if a full-refresh is required after this PR is merged. staging model check in hero Related work items: #25344
This commit is contained in:
commit
15fd885f8a
3 changed files with 222 additions and 0 deletions
8
models/staging/check_in_hero/_check_in_hero_sources.yml
Normal file
8
models/staging/check_in_hero/_check_in_hero_sources.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
version: 2
|
||||
|
||||
sources:
|
||||
- name: check_in_hero
|
||||
schema: sync_cdb_check_in_hero
|
||||
tables:
|
||||
- name: checkins
|
||||
identifier: checkins
|
||||
153
models/staging/check_in_hero/schema.yml
Normal file
153
models/staging/check_in_hero/schema.yml
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
version: 2
|
||||
|
||||
models:
|
||||
- name: stg_check_in_hero__checkins
|
||||
description: |
|
||||
Records of checkins using Checkin Hero API, capturing details about reservations,
|
||||
guests, accommodations, and booking details.
|
||||
columns:
|
||||
- name: id_record
|
||||
data_type: text
|
||||
description: Unique identifier for the record.
|
||||
tests:
|
||||
- unique
|
||||
- not_null
|
||||
|
||||
- name: id_user_partner
|
||||
data_type: text
|
||||
description: Identifier for the partner user associated with the check-in.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_reservation
|
||||
data_type: text
|
||||
description: Unique identifier for the reservation associated with the check-in.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: id_accommodation
|
||||
data_type: text
|
||||
description: Unique identifier for the accommodation associated with the reservation.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: guest_last_name
|
||||
data_type: text
|
||||
description: Last name of the guest checking in.
|
||||
|
||||
- name: guest_first_name
|
||||
data_type: text
|
||||
description: First name of the guest checking in.
|
||||
|
||||
- name: guest_email
|
||||
data_type: text
|
||||
description: Email address of the guest checking in.
|
||||
|
||||
- name: guest_telephone
|
||||
data_type: text
|
||||
description: Telephone number of the guest checking in.
|
||||
|
||||
- name: number_of_guests
|
||||
data_type: integer
|
||||
description: Total number of guests included in the check-in.
|
||||
|
||||
- name: reservation_total_amount_in_local_currency
|
||||
data_type: numeric
|
||||
description: Total cost amount in guest currency for the reservation.
|
||||
tests:
|
||||
- dbt_expectations.expect_column_values_to_be_between:
|
||||
min_value: 0
|
||||
strictly: true
|
||||
|
||||
- name: reservation_currency
|
||||
data_type: text
|
||||
description: |
|
||||
Currency ISO code used by guest for the reservation.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: channel
|
||||
data_type: text
|
||||
description: Booking channel or source.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: checkin_date_utc
|
||||
data_type: date
|
||||
description: Check-in date for the booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: checkin_time_utc
|
||||
data_type: time without time zone
|
||||
description: Time of check-in for the booking.
|
||||
|
||||
- name: checkout_date_utc
|
||||
data_type: date
|
||||
description: Check-out date for the booking.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: listing_name
|
||||
data_type: text
|
||||
description: Name of the listing associated with the check-in.
|
||||
|
||||
- name: listing_address
|
||||
data_type: text
|
||||
description: Address of the listing.
|
||||
|
||||
- name: listing_address_line_2
|
||||
data_type: text
|
||||
description: Additional address details for the listing.
|
||||
|
||||
- name: listing_town
|
||||
data_type: text
|
||||
description: Town or city where the listing is located.
|
||||
|
||||
- name: listing_country
|
||||
data_type: text
|
||||
description: Country code for the location of the listing.
|
||||
|
||||
- name: listing_postcode
|
||||
data_type: text
|
||||
description: Postal code for the listing.
|
||||
|
||||
- name: user_email
|
||||
data_type: text
|
||||
description: Email address of the user associated with the check-in.
|
||||
|
||||
- name: updated_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: Timestamp of the last update to the record.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: updated_date_utc
|
||||
data_type: date
|
||||
description: Date of the last update to the record.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: cosmos_creation_at_utc
|
||||
data_type: timestamp without time zone
|
||||
description: Timestamp when the record was created in Cosmos DB.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: cosmos_creation_date_utc
|
||||
data_type: date
|
||||
description: Date when the record was created in Cosmos DB.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: created_date_utc
|
||||
data_type: date
|
||||
description: Date when the record was created.
|
||||
tests:
|
||||
- not_null
|
||||
|
||||
- name: cosmos_db_timestamp_utc
|
||||
data_type: timestamp with time zone
|
||||
description: Internal Cosmos DB timestamp of the last record update.
|
||||
tests:
|
||||
- not_null
|
||||
61
models/staging/check_in_hero/stg_check_in_hero__checkins.sql
Normal file
61
models/staging/check_in_hero/stg_check_in_hero__checkins.sql
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
with
|
||||
raw_checkins as (select * from {{ source("check_in_hero", "checkins") }}),
|
||||
deduped_verifications as (
|
||||
{{ cosmos_db_record_deduplication("raw_checkins", "id") }}
|
||||
),
|
||||
stg_check_in_hero__checkins as (
|
||||
select
|
||||
{{ adapter.quote("documents") }} ->> 'id' as id_record,
|
||||
{{ adapter.quote("documents") }} ->> 'userId' as id_user_partner,
|
||||
{{ adapter.quote("documents") }} ->> 'ReservationId' as id_reservation,
|
||||
{{ adapter.quote("documents") }} ->> 'ListingId' as id_accommodation,
|
||||
{{ adapter.quote("documents") }} ->> 'GuestLastName' as guest_last_name,
|
||||
{{ adapter.quote("documents") }} ->> 'GuestFirstName' as guest_first_name,
|
||||
{{ adapter.quote("documents") }} ->> 'GuestEmail' as guest_email,
|
||||
{{ adapter.quote("documents") }}
|
||||
->> 'GuestTelephoneNumber' as guest_telephone,
|
||||
({{ adapter.quote("documents") }} ->> 'NumberOfGuests')::integer
|
||||
as number_of_guests,
|
||||
cast(
|
||||
case
|
||||
when
|
||||
{{ adapter.quote("documents") }} ->> 'ReservationTotalAmount'
|
||||
= ''
|
||||
then null
|
||||
else {{ adapter.quote("documents") }} ->> 'ReservationTotalAmount'
|
||||
end as decimal(19, 4)
|
||||
) as reservation_total_amount,
|
||||
{{ adapter.quote("documents") }}
|
||||
->> 'ReservationCurrency' as reservation_currency,
|
||||
{{ adapter.quote("documents") }} ->> 'Channel' as channel,
|
||||
({{ adapter.quote("documents") }} ->> 'CheckIn')::date as checkin_date_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'CheckInTime')::time
|
||||
as checkin_time_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'CheckOut')::date
|
||||
as checkout_date_utc,
|
||||
{{ adapter.quote("documents") }} ->> 'ListingName' as listing_name,
|
||||
{{ adapter.quote("documents") }} ->> 'AddressLine1' as listing_address,
|
||||
{{ adapter.quote("documents") }}
|
||||
->> 'AddressLine2' as listing_address_line_2,
|
||||
{{ adapter.quote("documents") }} ->> 'Town' as listing_town,
|
||||
{{ adapter.quote("documents") }} ->> 'CountryIso' as listing_country,
|
||||
{{ adapter.quote("documents") }} ->> 'Postcode' as listing_postcode,
|
||||
{{ adapter.quote("documents") }} ->> 'userEmail' as user_email,
|
||||
({{ adapter.quote("documents") }} ->> 'UpdatedDate')::timestamp
|
||||
as updated_at_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'UpdatedDate')::date
|
||||
as updated_date_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'CreatedDate')::timestamp
|
||||
as cosmos_creation_at_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'CreatedDate')::date
|
||||
as cosmos_creation_date_utc,
|
||||
({{ adapter.quote("documents") }} ->> 'CreationDate')::date
|
||||
as created_date_utc,
|
||||
to_timestamp(
|
||||
({{ adapter.quote("documents") }} ->> '_ts')::double precision
|
||||
) as cosmos_db_timestamp_utc
|
||||
|
||||
from deduped_verifications
|
||||
)
|
||||
select *
|
||||
from stg_check_in_hero__checkins
|
||||
Loading…
Add table
Add a link
Reference in a new issue