diff --git a/models/staging/core/_core_sources.yml b/models/staging/core/_core_sources.yml index ef159ba..8d83a3a 100644 --- a/models/staging/core/_core_sources.yml +++ b/models/staging/core/_core_sources.yml @@ -277,3 +277,23 @@ sources: identifier: StandaloneProtection - name: AccountType identifier: AccountType + - name: VerificationRequestToGuestProduct + identifier: VerificationRequestToGuestProduct + - name: VerificationRequestGuestProductToPayment + identifier: VerificationRequestGuestProductToPayment + + - name: guest_product + schema: sync_guest_product + tables: + - name: Product + identifier: Product + - name: Configuration + identifier: Configuration + - name: ConfigurationStatus + identifier: ConfigurationStatus + - name: ConfigurationLevel + identifier: ConfigurationLevel + - name: ConfigurationPricePlan + identifier: ConfigurationPricePlan + - name: DisplayDetail + identifier: DisplayDetail diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index a93cfcc..02ab299 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -1861,3 +1861,141 @@ models: Timestamp of when this record was extracted into DWH. data_tests: - not_null + + - name: stg_core__verification_request_to_guest_product + description: | + Contains the relationship between a Verification Request and a Guest Product. + This table is used to track the verification requests that are related to a + specific guest product. + + columns: + - name: id_verification_request_to_guest_product + data_type: bigint + description: | + Unique identifier of the verification request to guest product. + Acts as the primary key for this table. + data_tests: + - not_null + - unique + + - name: id_verification_request + data_type: bigint + description: | + Identifier of the verification request. + data_tests: + - not_null + + - name: id_guest_product + data_type: bigint + description: | + Identifier of the guest product. + data_tests: + - not_null + + - name: id_guest_product_configuration_price_plan + data_type: bigint + description: | + Identifier of the guest product configuration price plan. + data_tests: + - not_null + + - name: is_guest_product_purchased + data_type: boolean + description: | + Indicates if the guest product was purchased. + + - name: created_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was created. + data_tests: + - not_null + + - name: created_date_utc + data_type: date + description: | + Date of when this record was created. + data_tests: + - not_null + + - name: updated_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was last updated. + data_tests: + - not_null + + - name: updated_date_utc + data_type: date + description: | + Date of when this record was last updated. + data_tests: + - not_null + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was extracted into DWH. + + - name: stg_core__verification_request_guest_product_to_payment + description: | + Contains the relationship between a Verification Request with Guest Product and a Payment. + This table is used to track the verification requests from a guest product + to a payment. + + columns: + - name: id_verification_request_guest_product_to_payment + data_type: bigint + description: | + Unique identifier of the verification request to guest product to payment. + Acts as the primary key for this table. + data_tests: + - not_null + - unique + + - name: id_verification_request_to_guest_product + data_type: bigint + description: | + Identifier of the verification request to guest product. + data_tests: + - not_null + + - name: id_payment + data_type: bigint + description: | + Identifier of the payment. + data_tests: + - not_null + + - name: created_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was created. + data_tests: + - not_null + + - name: created_date_utc + data_type: date + description: | + Date of when this record was created. + data_tests: + - not_null + + - name: updated_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was last updated. + data_tests: + - not_null + + - name: updated_date_utc + data_type: date + description: | + Date of when this record was last updated. + data_tests: + - not_null + + - name: dwh_extracted_at_utc + data_type: timestamp with time zone + description: | + Timestamp of when this record was extracted into DWH. diff --git a/models/staging/core/stg_core__verification_request_guest_product_to_payment.sql b/models/staging/core/stg_core__verification_request_guest_product_to_payment.sql new file mode 100644 index 0000000..6c3c00a --- /dev/null +++ b/models/staging/core/stg_core__verification_request_guest_product_to_payment.sql @@ -0,0 +1,35 @@ +{{ + config( + materialized="incremental", + unique_key="id_verification_request_to_guest_product", + ) +}} + + +with + raw_verification_request_guest_product_to_payment as ( + select * from {{ source("core", "VerificationRequestGuestProductToPayment") }} + ), + stg_core__verification_request_guest_product_to_payment as ( + select + {{ adapter.quote("Id") }} + as id_verification_request_guest_product_to_payment, + {{ adapter.quote("PaymentId") }} as id_payment, + {{ adapter.quote("VerificationRequestToGuestProductId") }} + as id_verification_request_to_guest_product, + + {{ 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_verification_request_guest_product_to_payment + ) +select * +from stg_core__verification_request_guest_product_to_payment +{% if is_incremental() %} + where + updated_at_utc + >= ((select max(updated_at_utc) from {{ this }}) - interval '7 days') +{% endif %} diff --git a/models/staging/core/stg_core__verification_request_to_guest_product.sql b/models/staging/core/stg_core__verification_request_to_guest_product.sql new file mode 100644 index 0000000..466f231 --- /dev/null +++ b/models/staging/core/stg_core__verification_request_to_guest_product.sql @@ -0,0 +1,37 @@ +{{ + config( + materialized="incremental", + unique_key="id_verification_request_to_guest_product", + ) +}} + + +with + raw_verification_request_to_guest_product as ( + select * from {{ source("core", "VerificationRequestToGuestProduct") }} + ), + stg_core__verification_request_to_guest_product as ( + select + {{ adapter.quote("Id") }} as id_verification_request_to_guest_product, + {{ adapter.quote("GuestProductId") }} as id_guest_product, + {{ adapter.quote("VerificationRequestId") }} as id_verification_request, + {{ adapter.quote("GuestProductConfigurationPricePlanId") }} + as id_guest_product_configuration_price_plan, + + {{ adapter.quote("PurchasedByGuest") }} as is_guest_product_purchased, + + {{ 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_verification_request_to_guest_product + ) +select * +from stg_core__verification_request_to_guest_product +{% if is_incremental() %} + where + updated_at_utc + >= ((select max(updated_at_utc) from {{ this }}) - interval '7 days') +{% endif %}