Merged PR 3028: Adding int_core__user_product_bundle_contains_services

# Description

This PR adds a new table named `user_product_bundle_contains_services` in intermediate core.

Mainly, this table serves as a bridge between `user_product_bundle` and `product_services`. A `product_bundle` within `user_product_bundle` can contain 1 or several services, and this was stated in the field `contains_product_services`. The value of this field corresponds to the sum of `product_service_binary_tier` from the services that apply within that bundle. Even though the information is quite concise using this format, it adds extra complexity for analytical purposes, so this new table just duplicates the `user_product_bundle` main attributes as many times as services are contained.

For example:
`id_user_product_bundle` = 383 contains one unique bundle named Basic Program. This bundle has the `chosen_product_services` = 257, which can only be decomposed in power of 2 as of the sum of 256 + 1. This bundle therefore contains 2 services, Basic Screening (`product_service_binary_tier` = 1) and Waiver Pro (`product_service_binary_tier` = 256). Thus, in the new table, we will have 2 records and remove all this logic to something more standard, as seen in this screenshot:

![image (2).png](https://guardhog.visualstudio.com/4148d95f-4b6d-4205-bcff-e9c8e0d2ca65/_apis/git/repositories/54ac356f-aad7-46d2-b62c-e8c5b3bb8ebf/pullRequests/3028/attachments/image%20%282%29.png)

# Checklist

- [X] The edited models and dependants run properly with production 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 PK in this table, but the combination of columns that should be unique is tested*
- [X] I have checked for DRY opportunities with other models and docs.
- [X] I've picked the right materialization for the affected models.

# Other

- [ ] Check if a full-refresh is required after this PR is merged.

Related work items: #20809
This commit is contained in:
Oriol Roqué Paniagua 2024-10-02 14:54:03 +00:00
parent 34d0e9cffb
commit 8e4e967c20
2 changed files with 76 additions and 0 deletions

View file

@ -3416,3 +3416,60 @@ models:
- name: dwh_extracted_at_utc
data_type: timestamp with time zone
description: Timestamp of when this data was extracted into DWH.
- name: int_core__user_product_bundle_contains_services
description: |
This table contains the information of "this user has a certain product bundle which
contains these services."
It's a denormalised relationship to break the power of 2 link between chosen_product_services
and product_service_binary_tier, which allows standard joins using the ids.
tests:
- dbt_utils.unique_combination_of_columns:
combination_of_columns:
- id_user_product_bundle
- id_product_service
columns:
- name: id_user_product_bundle
data_type: bigint
description: |
The identifier of the record for a user having a product bundle. It's the foreign key
pointing to user_product_bundle.
tests:
- not_null
- name: id_user_host
data_type: string
description: |
The Superhog ID of the host user this record applies to.
tests:
- not_null
- name: id_product_bundle
data_type: bigint
description: |
The identifier of the product bundle.
tests:
- not_null
- name: id_product_service
data_type: bigint
description: |
The identifier of the product service.
tests:
- not_null
- name: product_bundle_name
data_type: string
description: |
The CamelCase name of the product bundle.
tests:
- not_null
- name: product_service_name
data_type: string
description: |
The CamelCase name of the product service.
tests:
- not_null