From 1f683ec6515a8f05c3b1d52d989bc880ceee75c4 Mon Sep 17 00:00:00 2001 From: Joaquin Ossa Date: Wed, 4 Dec 2024 16:33:50 +0100 Subject: [PATCH] Final clarifications --- ...een_and_protect__verification_requests.sql | 4 +- .../screen_and_protect/schema.yml | 39 ++++++++++++++++--- .../reporting/screen_and_protect/schema.yml | 39 ++++++++++++++++--- ...een_and_protect__verification_requests.sql | 4 +- models/staging/screen_and_protect/schema.yml | 39 ++++++++++++++++--- ...een_and_protect__verification_requests.sql | 33 +++++++++++++--- 6 files changed, 132 insertions(+), 26 deletions(-) diff --git a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql index 9c7aa12..e5eb745 100644 --- a/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql +++ b/models/intermediate/screen_and_protect/int_screen_and_protect__verification_requests.sql @@ -10,6 +10,7 @@ select id_user_partner, id_accommodation, protection_type, + protection_starting_level, protection_basic_amount, protection_extended_amount, pet_protection, @@ -43,6 +44,7 @@ select status_updated_date_utc, updated_at_utc, updated_date_utc, - created_at_utc, + cosmos_creation_at_utc, + cosmos_creation_date_utc, created_date_utc from stg_screen_and_protect__verification_requests diff --git a/models/intermediate/screen_and_protect/schema.yml b/models/intermediate/screen_and_protect/schema.yml index bf5ff8c..dfa5471 100644 --- a/models/intermediate/screen_and_protect/schema.yml +++ b/models/intermediate/screen_and_protect/schema.yml @@ -43,17 +43,35 @@ models: - "DAMAGE WAIVER" - "PET PROTECTION" - - name: protection_basic_amount + - name: protection_starting_level data_type: numeric - description: Basic protection amount for the booking. + description: Field used for protection type "STANDALONE PROTECTION" to + indicate the starting level of protection. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 + max_value: 100000 + strictly: true + + - name: protection_basic_amount + data_type: numeric + description: Field used for protection type "SCREEN & PROTECT", + "BASIC PROTECTION" or "DAMAGE WAIVER" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 100000 strictly: true - name: protection_extended_amount data_type: numeric - description: Extended protection amount for the booking. + description: Field used for protection type "SCREEN & PROTECT", + or "STANDALONE PROTECTION" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 50000000 + strictly: true - name: pet_protection data_type: boolean @@ -200,14 +218,23 @@ models: tests: - not_null - - name: created_at_utc + - name: cosmos_creation_at_utc data_type: timestamp without time zone - description: Internal timestamp when the record was created. + description: | + Timestamp of when the verification request was created in Cosmos DB. + tests: + - not_null + + - name: cosmos_creation_date_utc + data_type: date + description: | + Date of when the verification request was created in Cosmos DB. tests: - not_null - name: created_date_utc data_type: date - description: Internal date when the record was created. + description: | + Date when the reservation was created. tests: - not_null diff --git a/models/reporting/screen_and_protect/schema.yml b/models/reporting/screen_and_protect/schema.yml index a54c02f..a3c2857 100644 --- a/models/reporting/screen_and_protect/schema.yml +++ b/models/reporting/screen_and_protect/schema.yml @@ -43,17 +43,35 @@ models: - "DAMAGE WAIVER" - "PET PROTECTION" - - name: protection_basic_amount + - name: protection_starting_level data_type: numeric - description: Basic protection amount for the booking. + description: Field used for protection type "STANDALONE PROTECTION" to + indicate the starting level of protection. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 + max_value: 100000 + strictly: true + + - name: protection_basic_amount + data_type: numeric + description: Field used for protection type "SCREEN & PROTECT", + "BASIC PROTECTION" or "DAMAGE WAIVER" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 100000 strictly: true - name: protection_extended_amount data_type: numeric - description: Extended protection amount for the booking. + description: Field used for protection type "SCREEN & PROTECT", + or "STANDALONE PROTECTION" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 50000000 + strictly: true - name: pet_protection data_type: boolean @@ -200,14 +218,23 @@ models: tests: - not_null - - name: created_at_utc + - name: cosmos_creation_at_utc data_type: timestamp without time zone - description: Internal timestamp when the record was created. + description: | + Timestamp of when the verification request was created in Cosmos DB. + tests: + - not_null + + - name: cosmos_creation_date_utc + data_type: date + description: | + Date of when the verification request was created in Cosmos DB. tests: - not_null - name: created_date_utc data_type: date - description: Internal date when the record was created. + description: | + Date when the reservation was created. tests: - not_null diff --git a/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql b/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql index 1068351..39ecb73 100644 --- a/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql +++ b/models/reporting/screen_and_protect/screen_and_protect__verification_requests.sql @@ -10,6 +10,7 @@ select id_user_partner as id_user_partner, id_accommodation as id_accommodation, protection_type as protection_type, + protection_starting_level as protection_starting_level, protection_basic_amount as protection_basic_amount, protection_extended_amount as protection_extended_amount, pet_protection as pet_protection, @@ -43,6 +44,7 @@ select status_updated_date_utc as status_updated_date_utc, updated_at_utc as updated_at_utc, updated_date_utc as updated_date_utc, - created_at_utc as created_at_utc, + cosmos_creation_at_utc as cosmos_creation_at_utc, + cosmos_creation_date_utc as cosmos_creation_date_utc, created_date_utc as created_date_utc from int_screen_and_protect__verification_requests diff --git a/models/staging/screen_and_protect/schema.yml b/models/staging/screen_and_protect/schema.yml index 9a75127..ca2527e 100644 --- a/models/staging/screen_and_protect/schema.yml +++ b/models/staging/screen_and_protect/schema.yml @@ -43,17 +43,35 @@ models: - "DAMAGE WAIVER" - "PET PROTECTION" - - name: protection_basic_amount + - name: protection_starting_level data_type: numeric - description: Basic protection amount for the booking. + description: Field used for protection type "STANDALONE PROTECTION" to + indicate the starting level of protection. tests: - dbt_expectations.expect_column_values_to_be_between: min_value: 0 + max_value: 100000 + strictly: true + + - name: protection_basic_amount + data_type: numeric + description: Field used for protection type "SCREEN & PROTECT", + "BASIC PROTECTION" or "DAMAGE WAIVER" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 100000 strictly: true - name: protection_extended_amount data_type: numeric - description: Extended protection amount for the booking. + description: Field used for protection type "SCREEN & PROTECT", + or "STANDALONE PROTECTION" to show the basic amount of protection. + tests: + - dbt_expectations.expect_column_values_to_be_between: + min_value: 0 + max_value: 50000000 + strictly: true - name: pet_protection data_type: boolean @@ -196,15 +214,24 @@ models: tests: - not_null - - name: created_at_utc + - name: cosmos_creation_at_utc data_type: timestamp without time zone - description: Internal timestamp when the record was created. + description: | + Timestamp of when the verification request was created in Cosmos DB. + tests: + - not_null + + - name: cosmos_creation_date_utc + data_type: date + description: | + Date of when the verification request was created in Cosmos DB. tests: - not_null - name: created_date_utc data_type: date - description: Internal date when the record was created. + description: | + Date when the reservation was created. tests: - not_null diff --git a/models/staging/screen_and_protect/stg_screen_and_protect__verification_requests.sql b/models/staging/screen_and_protect/stg_screen_and_protect__verification_requests.sql index 8bcf185..8fb9a3e 100644 --- a/models/staging/screen_and_protect/stg_screen_and_protect__verification_requests.sql +++ b/models/staging/screen_and_protect/stg_screen_and_protect__verification_requests.sql @@ -15,12 +15,31 @@ with {{ adapter.quote("documents") }} ->> 'ProtectionType' ) as protection_type, cast( - {{ adapter.quote("documents") }} - ->> 'ProtectionBasicAmount' as decimal(19, 4) + case + when + {{ adapter.quote("documents") }} ->> 'ProtectionStartingLevel' + = '' + then null + else {{ adapter.quote("documents") }} ->> 'ProtectionStartingLevel' + end as decimal(19, 4) + ) as protection_starting_level, + cast( + case + when + {{ adapter.quote("documents") }} ->> 'ProtectionBasicAmount' + = '' + then null + else {{ adapter.quote("documents") }} ->> 'ProtectionBasicAmount' + end as decimal(19, 4) ) as protection_basic_amount, cast( - {{ adapter.quote("documents") }} - ->> 'ProtectionExtendedAmount' as decimal(19, 4) + case + when + {{ adapter.quote("documents") }} ->> 'ProtectionExtendedAmount' + = '' + then null + else {{ adapter.quote("documents") }} ->> 'ProtectionExtendedAmount' + end as decimal(19, 4) ) as protection_extended_amount, ({{ adapter.quote("documents") }} ->> 'PetProtection')::boolean as pet_protection, @@ -66,9 +85,11 @@ with as updated_at_utc, ({{ adapter.quote("documents") }} ->> 'UpdatedDate')::date as updated_date_utc, - ({{ adapter.quote("documents") }} ->> 'CreatedDate')::timestamp - as created_at_utc, + ({{ adapter.quote("documents") }} ->> 'CreationDate')::timestamp + as cosmos_creation_at_utc, ({{ adapter.quote("documents") }} ->> 'CreationDate')::date + as cosmos_creation_date_utc, + ({{ adapter.quote("documents") }} ->> 'CreatedDate')::date as created_date_utc, to_timestamp( (({{ adapter.quote("documents") }} ->> '_ts'))::integer