diff --git a/models/staging/core/_core_sources.yml b/models/staging/core/_core_sources.yml index 8d83a3a..1abc912 100644 --- a/models/staging/core/_core_sources.yml +++ b/models/staging/core/_core_sources.yml @@ -281,6 +281,8 @@ sources: identifier: VerificationRequestToGuestProduct - name: VerificationRequestGuestProductToPayment identifier: VerificationRequestGuestProductToPayment + - name: UserProductBundleToGuestProduct + identifier: UserProductBundleToGuestProduct - name: guest_product schema: sync_guest_product diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index c91e715..91b705f 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -2386,3 +2386,85 @@ models: data_type: timestamp with time zone description: | Timestamp of when this record was extracted into DWH. + + - name: stg_core__user_product_bundle_to_guest_product + description: | + Contains the relationship between a User Product Bundle and a Guest Product. + This table is used to track the guest products that are part of a user product bundle, + and whether these are enabled or not. + Note that user product bundles that do not contain an equivalent record in this table + indicate that the guest product is not enabled for that user product bundle. + Note that this table effectively only contains the last status in terms of enabled/disabled + guest products for a user product bundle. + + columns: + - name: id_user_product_bundle_to_guest_product + data_type: bigint + description: | + Unique identifier of the user product bundle to guest product. + Acts as the primary key for this table. + data_tests: + - not_null + - unique + + - name: id_user_product_bundle + data_type: bigint + description: | + Identifier of the user product bundle. + data_tests: + - not_null + + - name: id_guest_product + data_type: bigint + description: | + Identifier of the guest product. + data_tests: + - not_null + + - name: is_enabled + data_type: boolean + description: | + Indicates if the guest product is enabled or not. + - If true, then the guest product is enabled. + - If false, then the guest product is disabled. + data_tests: + - not_null + + - name: created_at_utc + data_type: timestamp + 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 + description: | + Timestamp of when this record was last updated. + Defaults to created_at_utc if the original record contains a + null UpdatedDate. + data_tests: + - not_null + + - name: updated_date_utc + data_type: date + description: | + Date of when this record was last updated. + Defaults to created_date_utc if the original record contains a + null UpdatedDate. + 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. + data_tests: + - not_null diff --git a/models/staging/core/stg_core__user_product_bundle_to_guest_product.sql b/models/staging/core/stg_core__user_product_bundle_to_guest_product.sql new file mode 100644 index 0000000..485f11e --- /dev/null +++ b/models/staging/core/stg_core__user_product_bundle_to_guest_product.sql @@ -0,0 +1,28 @@ +with + raw_user_product_bundle_to_guest_product as ( + select * from {{ source("core", "UserProductBundleToGuestProduct") }} + ), + stg_core__user_product_bundle_to_guest_product as ( + select + {{ adapter.quote("Id") }} as id_user_product_bundle_to_guest_product, + {{ adapter.quote("GuestProductId") }} as id_guest_product, + {{ adapter.quote("UserProductBundleId") }} as id_user_product_bundle, + {{ adapter.quote("IsEnabled") }} as is_enabled, + {{ adapter.quote("CreatedDate") }} as created_at_utc, + date({{ adapter.quote("CreatedDate") }}) as created_date_utc, + -- UpdatedDate is nullable. In these cases, we default to CreatedDate + coalesce( + {{ adapter.quote("UpdatedDate") }},{{ adapter.quote("CreatedDate") }} + ) as updated_at_utc, + date( + coalesce( + {{ adapter.quote("UpdatedDate") }}, + {{ adapter.quote("CreatedDate") }} + ) + ) as updated_date_utc, + {{ adapter.quote("_airbyte_extracted_at") }} as dwh_extracted_at_utc + + from raw_user_product_bundle_to_guest_product + ) +select * +from stg_core__user_product_bundle_to_guest_product