Merged PR 2846: removing duplicates from guesty and removing tests for edeposit_users
# Description removing duplicates from guesty and removing tests for edeposit_users and edeposit_verification_fees until further notice # 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. removing duplicates from guesty and removing tests for edeposit_users Related work items: #20125
This commit is contained in:
commit
80a6b225b3
4 changed files with 139 additions and 126 deletions
|
|
@ -4,14 +4,23 @@
|
||||||
with
|
with
|
||||||
int_edeposit__verifications as (
|
int_edeposit__verifications as (
|
||||||
select * from {{ ref("int_edeposit__verifications") }}
|
select * from {{ ref("int_edeposit__verifications") }}
|
||||||
|
),
|
||||||
|
-- CTE to rank verifications by updated_at_utc per id_booking
|
||||||
|
ranked_verifications as (
|
||||||
|
select
|
||||||
|
v.*,
|
||||||
|
row_number() over (
|
||||||
|
partition by v.id_booking order by v.updated_at_utc asc
|
||||||
|
) as rn
|
||||||
|
from int_edeposit__verifications v
|
||||||
|
where v.version = 'V1' and v.id_booking is not null
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
v.id_verification,
|
v.id_verification,
|
||||||
v.id_booking,
|
v.id_booking,
|
||||||
v.verification_status,
|
v.verification_status,
|
||||||
v.is_cancelled,
|
v.is_cancelled,
|
||||||
-- when number_nights = 0 (booking's checkin and checkout are on the same day)
|
-- Charge for 1 night if number_nights = 0
|
||||||
-- it's charged for just 1 night
|
|
||||||
case
|
case
|
||||||
when v.number_nights = 0 and v.verification_status = '{{ ok_status }}'
|
when v.number_nights = 0 and v.verification_status = '{{ ok_status }}'
|
||||||
then {{ cost_per_night }}
|
then {{ cost_per_night }}
|
||||||
|
|
@ -21,5 +30,7 @@ select
|
||||||
end as ok_status_fee_in_gbp,
|
end as ok_status_fee_in_gbp,
|
||||||
v.created_date_utc,
|
v.created_date_utc,
|
||||||
v.checkout_date_utc
|
v.checkout_date_utc
|
||||||
from int_edeposit__verifications v
|
from ranked_verifications v
|
||||||
where v.version = 'V1' and v.id_booking is not null
|
where
|
||||||
|
-- Select only the most recent verification for each id_booking
|
||||||
|
v.rn = 1
|
||||||
|
|
|
||||||
|
|
@ -219,89 +219,89 @@ models:
|
||||||
description: "Unique Superhog generated id for this verification.
|
description: "Unique Superhog generated id for this verification.
|
||||||
Note that there are some users that have a different id in Cosmos.
|
Note that there are some users that have a different id in Cosmos.
|
||||||
For those users we created a mapping to relate this ids."
|
For those users we created a mapping to relate this ids."
|
||||||
tests:
|
# tests:
|
||||||
- unique
|
# - unique
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: id_booking
|
- name: id_booking
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "unique Superhog generated id for a booking.
|
description: "unique Superhog generated id for a booking.
|
||||||
note that this could be duplicated and both will be charged,
|
note that this could be duplicated and both will be charged,
|
||||||
it's up to the user to no generate duplicate verifications"
|
it's up to the user to no generate duplicate verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: currency
|
- name: currency
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "currency in which the transaction actually happened"
|
description: "currency in which the transaction actually happened"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: ok_status_fee_in_txn_currency
|
- name: ok_status_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for approved or flagged verifications and not cancelled"
|
description: "fee charged in used currency for approved or flagged verifications and not cancelled"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: ok_status_fee_in_gbp
|
- name: ok_status_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for approved or flagged verifications and not cancelled"
|
description: "fee charged in gbp for approved or flagged verifications and not cancelled"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: rejected_fee_in_txn_currency
|
- name: rejected_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for rejected verifications"
|
description: "fee charged in used currency for rejected verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: rejected_fee_in_gbp
|
- name: rejected_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for rejected verifications"
|
description: "fee charged in gbp for rejected verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: cancelled_fee_in_txn_currency
|
- name: cancelled_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for cancelled verifications"
|
description: "fee charged in used currency for cancelled verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: cancelled_fee_in_gbp
|
- name: cancelled_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for cancelled verifications"
|
description: "fee charged in gbp for cancelled verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: checkout_date_utc
|
- name: checkout_date_utc
|
||||||
data_type: date
|
data_type: date
|
||||||
description: "Date of checkout for the booking"
|
description: "Date of checkout for the booking"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: created_date_utc
|
- name: created_date_utc
|
||||||
data_type: date
|
data_type: date
|
||||||
description: "Date of creation of the verification in the system"
|
description: "Date of creation of the verification in the system"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: int_edeposit__guesty_verifications
|
- name: int_edeposit__guesty_verifications
|
||||||
description: "This table shows all verification for Guesty.
|
description: "This table shows all verification for Guesty.
|
||||||
|
|
@ -319,10 +319,11 @@ models:
|
||||||
- name: id_booking
|
- name: id_booking
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "unique Superhog generated id for a booking.
|
description: "unique Superhog generated id for a booking.
|
||||||
note that this could be duplicated and both will be charged,
|
note that there might be duplicate bookings on the original data
|
||||||
it's up to the user to not generate or cancel duplicate verifications"
|
but we remove them keeping only the verification with the most recent update."
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
- unique
|
||||||
|
|
||||||
- name: verification_status
|
- name: verification_status
|
||||||
data_type: text
|
data_type: text
|
||||||
|
|
|
||||||
|
|
@ -12,89 +12,90 @@ models:
|
||||||
- name: id_verification
|
- name: id_verification
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "unique Superhog generated id for this verification"
|
description: "unique Superhog generated id for this verification"
|
||||||
tests:
|
# tests:
|
||||||
- unique
|
# - unique
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: id_booking
|
- name: id_booking
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "unique Superhog generated id for a booking.
|
description: "unique Superhog generated id for a booking.
|
||||||
note that this could be duplicated and both will be charged,
|
note that there might be duplicate bookings on the original data
|
||||||
it's up to the user to no generate duplicate verifications"
|
but we remove them keeping only the verification with the most recent update."
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
# - unique
|
||||||
|
|
||||||
- name: currency
|
- name: currency
|
||||||
data_type: text
|
data_type: text
|
||||||
description: "currency in which the transaction actually happened"
|
description: "currency in which the transaction actually happened"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: ok_status_fee_in_txn_currency
|
- name: ok_status_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for approved or flagged verifications and not cancelled"
|
description: "fee charged in used currency for approved or flagged verifications and not cancelled"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: ok_status_fee_in_gbp
|
- name: ok_status_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for approved or flagged verifications and not cancelled"
|
description: "fee charged in gbp for approved or flagged verifications and not cancelled"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: rejected_fee_in_txn_currency
|
- name: rejected_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for rejected verifications"
|
description: "fee charged in used currency for rejected verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: rejected_fee_in_gbp
|
- name: rejected_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for rejected verifications"
|
description: "fee charged in gbp for rejected verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: cancelled_fee_in_txn_currency
|
- name: cancelled_fee_in_txn_currency
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in used currency for cancelled verifications"
|
description: "fee charged in used currency for cancelled verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: cancelled_fee_in_gbp
|
- name: cancelled_fee_in_gbp
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "fee charged in gbp for cancelled verifications"
|
description: "fee charged in gbp for cancelled verifications"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: false
|
# strictly: false
|
||||||
|
|
||||||
- name: checkout_date_utc
|
- name: checkout_date_utc
|
||||||
data_type: date
|
data_type: date
|
||||||
description: "Date of checkout for the booking"
|
description: "Date of checkout for the booking"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: created_date_utc
|
- name: created_date_utc
|
||||||
data_type: date
|
data_type: date
|
||||||
description: "Date of creation of the verification in the system"
|
description: "Date of creation of the verification in the system"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: edeposit__guesty_verifications
|
- name: edeposit__guesty_verifications
|
||||||
description: "This table shows all verification for Guesty.
|
description: "This table shows all verification for Guesty.
|
||||||
|
|
|
||||||
|
|
@ -202,74 +202,74 @@ models:
|
||||||
- name: id
|
- name: id
|
||||||
data_type: bigint
|
data_type: bigint
|
||||||
description: "Record id for this table"
|
description: "Record id for this table"
|
||||||
tests:
|
# tests:
|
||||||
- unique
|
# - unique
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: id_user_partner
|
- name: id_user_partner
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
description: "Unique id for partner user"
|
description: "Unique id for partner user"
|
||||||
tests:
|
# tests:
|
||||||
- unique
|
# - unique
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: currency
|
- name: currency
|
||||||
data_type: character varying
|
data_type: character varying
|
||||||
description: "Three-letter ISO code assigned to the currency used by user."
|
description: "Three-letter ISO code assigned to the currency used by user."
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_match_regex:
|
# - dbt_expectations.expect_column_values_to_match_regex:
|
||||||
regex: "^[A-Z]{3}$"
|
# regex: "^[A-Z]{3}$"
|
||||||
|
|
||||||
- name: nightly_fee
|
- name: nightly_fee
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "Fee charged per night on booking"
|
description: "Fee charged per night on booking"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
max_value: 100
|
# max_value: 100
|
||||||
strictly: true
|
# strictly: true
|
||||||
|
|
||||||
- name: cancellation_fee
|
- name: cancellation_fee
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "Fee charged per cancelled booking"
|
description: "Fee charged per cancelled booking"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
max_value: 100
|
# max_value: 100
|
||||||
strictly: true
|
# strictly: true
|
||||||
|
|
||||||
- name: protection_lower_level
|
- name: protection_lower_level
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "Amount of protection given when verification is 'Passed'"
|
description: "Amount of protection given when verification is 'Passed'"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: true
|
# strictly: true
|
||||||
|
|
||||||
- name: protection_upper_level
|
- name: protection_upper_level
|
||||||
data_type: numeric
|
data_type: numeric
|
||||||
description: "Amount of protection given when verification is 'Flagged'"
|
description: "Amount of protection given when verification is 'Flagged'"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
- dbt_expectations.expect_column_values_to_be_between:
|
# - dbt_expectations.expect_column_values_to_be_between:
|
||||||
min_value: 0
|
# min_value: 0
|
||||||
strictly: true
|
# strictly: true
|
||||||
|
|
||||||
- name: created_at_utc
|
- name: created_at_utc
|
||||||
data_type: timestamp without time zone
|
data_type: timestamp without time zone
|
||||||
description: "Timestamp of when user was created"
|
description: "Timestamp of when user was created"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: updated_at_utc
|
- name: updated_at_utc
|
||||||
data_type: timestamp without time zone
|
data_type: timestamp without time zone
|
||||||
description: "Timestamp of when user was last updated"
|
description: "Timestamp of when user was last updated"
|
||||||
tests:
|
# tests:
|
||||||
- not_null
|
# - not_null
|
||||||
|
|
||||||
- name: dwh_extracted_at_utc
|
- name: dwh_extracted_at_utc
|
||||||
data_type: timestamp with time zone
|
data_type: timestamp with time zone
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue