From cb3d1e628bd5f0e3d57931b0402b1de50338a12d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Roqu=C3=A9=20Paniagua?= Date: Tue, 27 Aug 2024 08:57:23 +0000 Subject: [PATCH] Merged PR 2647: Adding accommodation_to_product_bundle to stg # Description Adds accommodation to product bundle table from sync_core to staging. Note that this table still has no data because so far no listing has an associated product bundle. Small change: removed in schema pending confirmation comments from Lou now that we've got an answer confirming it. # Checklist - [ ] The edited models and dependants run properly with production data: **N/A - there's no data :(** - [X] The edited models are sufficiently documented. - [ ] The edited models contain PK tests, and I've ran and passed them. **N/A - there's no data :(** - [X] I have checked for DRY opportunities with other models and docs. - [ ] I've picked the right materialization for the affected models. **N/A - there's no data :(** # Other - [ ] Check if a full-refresh is required after this PR is merged. Related work items: #19570 --- models/intermediate/core/schema.yaml | 5 ++-- models/staging/core/_core_sources.yml | 2 ++ models/staging/core/schema.yml | 6 +++++ ..._core__accommodation_to_product_bundle.sql | 24 +++++++++++++++++++ 4 files changed, 34 insertions(+), 3 deletions(-) create mode 100644 models/staging/core/stg_core__accommodation_to_product_bundle.sql diff --git a/models/intermediate/core/schema.yaml b/models/intermediate/core/schema.yaml index c77c05a..38405f0 100644 --- a/models/intermediate/core/schema.yaml +++ b/models/intermediate/core/schema.yaml @@ -2292,7 +2292,7 @@ models: Important: A User having an active Product Bundle does NOT mean that the bundle is in use. - In order to be in use, the Product Bundle needs to be applied to a Listing. + In order to be in use, the Product Bundle needs to be applied to a Listing. Thus, the relationship in this table only shows, from user point of view, what Product Bundles she/he can apply into a Listing. @@ -2331,7 +2331,7 @@ models: data_type: int description: | The identifier of the Protection Plan. There's a 1 to 1 relationship between - a Product Bundle and a Protection Plan. Pending confirmation of Lou D. + a Product Bundle and a Protection Plan. - name: product_bundle_name data_type: string @@ -2347,7 +2347,6 @@ models: data_type: boolean description: | Flag that accounts for the capacity of a Host being able to modify the Product Bundle. - Pending confirmation of Lou D. - name: chosen_product_services data_type: int diff --git a/models/staging/core/_core_sources.yml b/models/staging/core/_core_sources.yml index f03d035..979f2ff 100644 --- a/models/staging/core/_core_sources.yml +++ b/models/staging/core/_core_sources.yml @@ -229,3 +229,5 @@ sources: identifier: AddressValidation - name: VerificationToAddressValidation identifier: VerificationToAddressValidation + - name: AccommodationToProductBundle + identifier: AccommodationToProductBundle \ No newline at end of file diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index 3985ff4..bac53e6 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -185,6 +185,12 @@ models: - unique - not_null - name: id_address_validation + tests: + - unique + - not_null + - name: stg_core__accommodation_to_product_bundle + columns: + - name: id_accommodation_to_product_bundle tests: - unique - not_null \ No newline at end of file diff --git a/models/staging/core/stg_core__accommodation_to_product_bundle.sql b/models/staging/core/stg_core__accommodation_to_product_bundle.sql new file mode 100644 index 0000000..0a0b1db --- /dev/null +++ b/models/staging/core/stg_core__accommodation_to_product_bundle.sql @@ -0,0 +1,24 @@ +with + raw_accommodation_to_product_bundle as ( + select * from {{ source("core", "AccommodationToProductBundle") }} + ), + stg_core__accommodation_to_product_bundle as ( + select + {{ adapter.quote("Id") }} as id_accommodation_to_product_bundle, + {{ adapter.quote("AccommodationId") }} as id_accommodation, + {{ adapter.quote("UserProductBundleId") }} as id_user_product_bundle, + {{ adapter.quote("StartDate") }} as starts_at_utc, + {{ adapter.quote("EndDate") }} as ends_at_utc, + case + when {{ adapter.quote("EndDate") }} is null then true else false + end as has_no_end_date, + {{ 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 + + from raw_accommodation_to_product_bundle + ) +select * +from stg_core__accommodation_to_product_bundle