From d6f30a8e67e3b76e79cea108a2c66ad046bc933c Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 3 Dec 2024 10:37:05 +0100 Subject: [PATCH 1/5] Added missing values --- models/intermediate/athena/int_athena__verifications.sql | 7 ++++++- models/intermediate/athena/schema.yml | 4 ++++ .../cross/int_edeposit_and_athena_verifications.sql | 6 ++++++ models/intermediate/cross/schema.yml | 8 ++++++-- .../intermediate/edeposit/int_edeposit__verifications.sql | 1 + .../reporting/cross/edeposit_and_athena_verifications.sql | 3 +++ models/reporting/cross/schema.yml | 8 ++++++-- 7 files changed, 32 insertions(+), 5 deletions(-) diff --git a/models/intermediate/athena/int_athena__verifications.sql b/models/intermediate/athena/int_athena__verifications.sql index b54e6a4..80e5b93 100644 --- a/models/intermediate/athena/int_athena__verifications.sql +++ b/models/intermediate/athena/int_athena__verifications.sql @@ -1,3 +1,5 @@ +{% set nightly_fee_local = 2 %} + with stg_athena__verifications as (select * from {{ ref("stg_athena__verifications") }}) select -- note that these ids are not the same as the ones found in Core DWH @@ -9,7 +11,7 @@ select version, case when version = 'V1' then 'Guesty' else null end as verification_source, verification_status, - nightly_fee_local, + {{ nightly_fee_local }} as nightly_fee_local, cast(checkout_at_utc as date) - cast(checkin_at_utc as date) as number_nights, email_flag, phone_flag, @@ -31,9 +33,12 @@ select property_manager_name, property_manager_email, listing_name, + listing_address, listing_town, listing_country, listing_postcode, + level_of_protection_amount, + level_of_protection_currency, pets_allowed, status_updated_at_utc, status_updated_date_utc, diff --git a/models/intermediate/athena/schema.yml b/models/intermediate/athena/schema.yml index d081148..ae5d762 100644 --- a/models/intermediate/athena/schema.yml +++ b/models/intermediate/athena/schema.yml @@ -143,6 +143,10 @@ models: data_type: text description: "" + - name: listing_address + data_type: text + description: "" + - name: listing_town data_type: text description: "" diff --git a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql index db43c0b..0534517 100644 --- a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql +++ b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql @@ -34,9 +34,12 @@ select av.property_manager_name, av.property_manager_email, av.listing_name, + av.listing_address, av.listing_town, av.listing_country, av.listing_postcode, + av.level_of_protection_amount, + av.level_of_protection_currency, av.pets_allowed, av.status_updated_at_utc, av.status_updated_date_utc, @@ -78,9 +81,12 @@ select ev.property_manager_name, ev.property_manager_email, ev.listing_name, + ev.listing_address, ev.listing_town, ev.listing_country, ev.listing_postcode, + null as level_of_protection_amount, + null as level_of_protection_currency, ev.pets_allowed, ev.status_updated_at_utc, ev.status_updated_date_utc, diff --git a/models/intermediate/cross/schema.yml b/models/intermediate/cross/schema.yml index efef2f1..cd6a8e0 100644 --- a/models/intermediate/cross/schema.yml +++ b/models/intermediate/cross/schema.yml @@ -1240,7 +1240,7 @@ models: - name: nightly_fee_local data_type: double precision - description: "fee charged per night" + description: "fee in local currency charged per night" - name: number_nights data_type: integer @@ -1248,7 +1248,7 @@ models: - name: total_fee_local data_type: double precision - description: "total fee for the booking" + description: "total fee in local currency for the booking" - name: email_flag data_type: text @@ -1330,6 +1330,10 @@ models: data_type: text description: "" + - name: listing_address + data_type: text + description: "" + - name: listing_town data_type: text description: "" diff --git a/models/intermediate/edeposit/int_edeposit__verifications.sql b/models/intermediate/edeposit/int_edeposit__verifications.sql index a7c8df0..8bd31ba 100644 --- a/models/intermediate/edeposit/int_edeposit__verifications.sql +++ b/models/intermediate/edeposit/int_edeposit__verifications.sql @@ -34,6 +34,7 @@ select property_manager_name, property_manager_email, listing_name, + listing_address, listing_town, listing_country, listing_postcode, diff --git a/models/reporting/cross/edeposit_and_athena_verifications.sql b/models/reporting/cross/edeposit_and_athena_verifications.sql index 8a50fdd..a66e96c 100644 --- a/models/reporting/cross/edeposit_and_athena_verifications.sql +++ b/models/reporting/cross/edeposit_and_athena_verifications.sql @@ -33,9 +33,12 @@ select eav.property_manager_name as property_manager_name, eav.property_manager_email as property_manager_email, eav.listing_name as listing_name, + eav.listing_address as listing_address, eav.listing_town as listing_town, eav.listing_country as listing_country, eav.listing_postcode as listing_postcode, + eav.level_of_protection_amount as level_of_protection_amount, + eav.level_of_protection_currency as level_of_protection_currency, eav.pets_allowed as pets_allowed, eav.status_updated_at_utc as status_updated_at_utc, eav.status_updated_date_utc as status_updated_date_utc, diff --git a/models/reporting/cross/schema.yml b/models/reporting/cross/schema.yml index 7587529..9d95d0d 100644 --- a/models/reporting/cross/schema.yml +++ b/models/reporting/cross/schema.yml @@ -57,7 +57,7 @@ models: - name: nightly_fee_local data_type: double precision - description: "fee charged per night" + description: "fee in local currency charged per night" - name: number_nights data_type: integer @@ -65,7 +65,7 @@ models: - name: total_fee_local data_type: double precision - description: "total fee for the booking" + description: "total fee in local currency for the booking" - name: email_flag data_type: text @@ -147,6 +147,10 @@ models: data_type: text description: "" + - name: listing_address + data_type: text + description: "" + - name: listing_town data_type: text description: "" From 5e17ca93a740239e6ff23f88e519396e8c405658 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 3 Dec 2024 10:42:03 +0100 Subject: [PATCH 2/5] Included level of protection --- .../cross/int_edeposit_and_athena_verifications.sql | 4 ++-- models/intermediate/edeposit/int_edeposit__verifications.sql | 2 ++ models/intermediate/edeposit/schema.yml | 4 ++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql index 0534517..e965450 100644 --- a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql +++ b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql @@ -85,8 +85,8 @@ select ev.listing_town, ev.listing_country, ev.listing_postcode, - null as level_of_protection_amount, - null as level_of_protection_currency, + ev.level_of_protection_amount, + ev.level_of_protection_currency, ev.pets_allowed, ev.status_updated_at_utc, ev.status_updated_date_utc, diff --git a/models/intermediate/edeposit/int_edeposit__verifications.sql b/models/intermediate/edeposit/int_edeposit__verifications.sql index 8bd31ba..b9beac1 100644 --- a/models/intermediate/edeposit/int_edeposit__verifications.sql +++ b/models/intermediate/edeposit/int_edeposit__verifications.sql @@ -38,6 +38,8 @@ select listing_town, listing_country, listing_postcode, + level_of_protection_amount, + level_of_protection_currency, pets_allowed, status_updated_at_utc, status_updated_date_utc, diff --git a/models/intermediate/edeposit/schema.yml b/models/intermediate/edeposit/schema.yml index 9356e25..ef5f26f 100644 --- a/models/intermediate/edeposit/schema.yml +++ b/models/intermediate/edeposit/schema.yml @@ -144,6 +144,10 @@ models: data_type: text description: "" + - name: listing_address + data_type: text + description: "" + - name: listing_town data_type: text description: "" From 4d0c45e49d268f1659402fb9f69e8b71acda6a93 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 3 Dec 2024 10:46:01 +0100 Subject: [PATCH 3/5] updated schemas --- models/intermediate/athena/schema.yml | 2 +- models/intermediate/edeposit/schema.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/models/intermediate/athena/schema.yml b/models/intermediate/athena/schema.yml index ae5d762..9eedd9e 100644 --- a/models/intermediate/athena/schema.yml +++ b/models/intermediate/athena/schema.yml @@ -57,7 +57,7 @@ models: - name: nightly_fee_local data_type: double precision - description: "fee charged per night" + description: "fee in local currency charged per night" - name: number_nights data_type: integer diff --git a/models/intermediate/edeposit/schema.yml b/models/intermediate/edeposit/schema.yml index ef5f26f..69bcdeb 100644 --- a/models/intermediate/edeposit/schema.yml +++ b/models/intermediate/edeposit/schema.yml @@ -58,7 +58,7 @@ models: - name: nightly_fee_local data_type: double precision - description: "fee charged per night" + description: "fee in local currency charged per night" - name: number_nights data_type: integer From 63b3cae062d3f553ad8108a62c13932ece0750cb Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 3 Dec 2024 11:35:03 +0100 Subject: [PATCH 4/5] Removed null fields --- .../athena/int_athena__verifications.sql | 2 -- models/intermediate/athena/schema.yml | 8 -------- .../int_edeposit_and_athena_verifications.sql | 18 +++++++++++------- .../edeposit/int_edeposit__verifications.sql | 4 ---- models/intermediate/edeposit/schema.yml | 16 ---------------- 5 files changed, 11 insertions(+), 37 deletions(-) diff --git a/models/intermediate/athena/int_athena__verifications.sql b/models/intermediate/athena/int_athena__verifications.sql index 80e5b93..69c83af 100644 --- a/models/intermediate/athena/int_athena__verifications.sql +++ b/models/intermediate/athena/int_athena__verifications.sql @@ -7,7 +7,6 @@ select id_verification, id_booking, id_user_partner, - id_accommodation, version, case when version = 'V1' then 'Guesty' else null end as verification_source, verification_status, @@ -29,7 +28,6 @@ select guest_last_name, guest_first_name, guest_telephone, - company_name, property_manager_name, property_manager_email, listing_name, diff --git a/models/intermediate/athena/schema.yml b/models/intermediate/athena/schema.yml index 9eedd9e..81aaffb 100644 --- a/models/intermediate/athena/schema.yml +++ b/models/intermediate/athena/schema.yml @@ -30,10 +30,6 @@ models: tests: - not_null - - name: id_accommodation - data_type: text - description: "unique Superhog generated id for a listing" - - name: version data_type: text description: "value to identify if it is Guesty (V1) or E-deposit (V2)" @@ -127,10 +123,6 @@ models: data_type: text description: "" - - name: company_name - data_type: text - description: "" - - name: property_manager_name data_type: text description: "" diff --git a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql index e965450..21a63f3 100644 --- a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql +++ b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql @@ -7,13 +7,17 @@ select av.id_verification, av.id_booking, av.id_user_partner, - av.id_accommodation, + null as id_accommodation, av.version, av.verification_source, av.verification_status, av.nightly_fee_local, av.number_nights, - av.nightly_fee_local * av.number_nights as total_fee_local, + case + when av.number_nights = 0 + then av.nightly_fee_local + else av.nightly_fee_local * av.number_nights + end as total_fee_local, av.email_flag, av.phone_flag, av.watch_list, @@ -30,7 +34,7 @@ select av.guest_last_name, av.guest_first_name, av.guest_telephone, - av.company_name, + null as company_name, av.property_manager_name, av.property_manager_email, av.listing_name, @@ -78,15 +82,15 @@ select ev.guest_first_name, ev.guest_telephone, ev.company_name, - ev.property_manager_name, - ev.property_manager_email, + null as property_manager_name, + null as property_manager_email, ev.listing_name, ev.listing_address, ev.listing_town, ev.listing_country, ev.listing_postcode, - ev.level_of_protection_amount, - ev.level_of_protection_currency, + null as level_of_protection_amount, + null as level_of_protection_currency, ev.pets_allowed, ev.status_updated_at_utc, ev.status_updated_date_utc, diff --git a/models/intermediate/edeposit/int_edeposit__verifications.sql b/models/intermediate/edeposit/int_edeposit__verifications.sql index b9beac1..6a27804 100644 --- a/models/intermediate/edeposit/int_edeposit__verifications.sql +++ b/models/intermediate/edeposit/int_edeposit__verifications.sql @@ -31,15 +31,11 @@ select guest_first_name, guest_telephone, company_name, - property_manager_name, - property_manager_email, listing_name, listing_address, listing_town, listing_country, listing_postcode, - level_of_protection_amount, - level_of_protection_currency, pets_allowed, status_updated_at_utc, status_updated_date_utc, diff --git a/models/intermediate/edeposit/schema.yml b/models/intermediate/edeposit/schema.yml index 69bcdeb..79bd29b 100644 --- a/models/intermediate/edeposit/schema.yml +++ b/models/intermediate/edeposit/schema.yml @@ -132,14 +132,6 @@ models: data_type: text description: "" - - name: property_manager_name - data_type: text - description: "" - - - name: property_manager_email - data_type: text - description: "" - - name: listing_name data_type: text description: "" @@ -164,14 +156,6 @@ models: data_type: boolean description: "" - - name: level_of_protection_amount - data_type: integer - description: "" - - - name: level_of_protection_currency - data_type: text - description: "" - - name: status_updated_at_utc data_type: timestamp without time zone description: "Timestamp when status was last updated" From 1af03e2b42a85765908fada35b0332be45429970 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Tue, 3 Dec 2024 11:58:42 +0100 Subject: [PATCH 5/5] included id_accommodation --- models/intermediate/athena/int_athena__verifications.sql | 1 + models/intermediate/athena/schema.yml | 4 ++++ .../cross/int_edeposit_and_athena_verifications.sql | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/models/intermediate/athena/int_athena__verifications.sql b/models/intermediate/athena/int_athena__verifications.sql index 69c83af..97e5c30 100644 --- a/models/intermediate/athena/int_athena__verifications.sql +++ b/models/intermediate/athena/int_athena__verifications.sql @@ -7,6 +7,7 @@ select id_verification, id_booking, id_user_partner, + id_accommodation, version, case when version = 'V1' then 'Guesty' else null end as verification_source, verification_status, diff --git a/models/intermediate/athena/schema.yml b/models/intermediate/athena/schema.yml index 81aaffb..4ec24d2 100644 --- a/models/intermediate/athena/schema.yml +++ b/models/intermediate/athena/schema.yml @@ -30,6 +30,10 @@ models: tests: - not_null + - name: id_accommodation + data_type: text + description: "unique Superhog generated id for a listing" + - name: version data_type: text description: "value to identify if it is Guesty (V1) or E-deposit (V2)" diff --git a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql index 21a63f3..84ad94a 100644 --- a/models/intermediate/cross/int_edeposit_and_athena_verifications.sql +++ b/models/intermediate/cross/int_edeposit_and_athena_verifications.sql @@ -7,7 +7,7 @@ select av.id_verification, av.id_booking, av.id_user_partner, - null as id_accommodation, + av.id_accommodation, av.version, av.verification_source, av.verification_status,