From e8f7278032a135dfd52c172d0c8fef6e765bd80e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oriol=20Roqu=C3=A9=20Paniagua?= Date: Tue, 3 Dec 2024 16:01:23 +0000 Subject: [PATCH] Merged PR 3756: First version of verification request feature flag # Description Brings VerificationRequestFeatureFlag to staging. Needs further modelling to clean data for A/B test tracking purposes, but this will be done in intermediate. # Checklist - [X] The edited models and dependants run properly with production data. - [X] The edited models are sufficiently documented. - [X] The edited models contain PK tests, and I've ran and passed them. - [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: #25145 --- models/staging/core/_core_sources.yml | 2 + models/staging/core/schema.yml | 77 +++++++++++++++++++ ...ore__verification_request_feature_flag.sql | 33 ++++++++ 3 files changed, 112 insertions(+) create mode 100644 models/staging/core/stg_core__verification_request_feature_flag.sql diff --git a/models/staging/core/_core_sources.yml b/models/staging/core/_core_sources.yml index 25a793b..1157e91 100644 --- a/models/staging/core/_core_sources.yml +++ b/models/staging/core/_core_sources.yml @@ -261,3 +261,5 @@ sources: identifier: ProductProtectionPlanBillingItem - name: ProductServiceBillingItem identifier: ProductServiceBillingItem + - name: VerificationRequestFeatureFlag + identifier: VerificationRequestFeatureFlag diff --git a/models/staging/core/schema.yml b/models/staging/core/schema.yml index 83f93c8..8645bf0 100644 --- a/models/staging/core/schema.yml +++ b/models/staging/core/schema.yml @@ -1281,3 +1281,80 @@ models: data_type: timestamp description: | Timestamp of when this record was extracted into DWH. + + - name: stg_core__verification_request_feature_flag + description: | + Provides the Feature Flag and the variation a given Verification Request is in. + Mostly used for A/B test tracking purposes on the scope of the Guest Journey. + + columns: + - name: id_verification_request_feature_flag + data_type: integer + description: | + Identifier of the Verification Request Feature Flag. Acts as the primary key for this table. + tests: + - unique + - not_null + + - name: id_verification_request + data_type: integer + description: | + Identifier of the Verification Request. Acts as foreign key to the Verification Request table. + It can be duplicated across different Feature Flags - meaning the same verification request + can be part of none, one, or several A/B tests. + tests: + - not_null + + - name: feature_flag_name + data_type: string + description: | + Name of the Feature Flag, or the Guest Journey A/B test. Cannot be null. + tests: + - not_null + + - name: feature_flag_variation + data_type: string + description: | + Identifier of the variation a given Verification Request is in, within a + given Feature Flag, or Guest Journey A/B test. It can be null. + + - name: is_feature_flag_enabled + data_type: boolean + description: | + Identifies whether the feature flag was enabled or disabled. In other words, + if the A/B test was active or not. In these cases, the feature flag variation + of the Guest Journeys would receive the default variation value (the control + group, generally speaking). + + - name: created_at_utc + data_type: timestamp + description: | + Timestamp of when this Verification Request Feature Flag record was created. + tests: + - not_null + + - name: created_date_utc + data_type: date + description: | + Date of when this Verification Request Feature Flag record was created. + tests: + - not_null + + - name: updated_at_utc + data_type: timestamp + description: | + Timestamp of when this Verification Request Feature Flag record was last updated. + tests: + - not_null + + - name: updated_date_utc + data_type: date + description: | + Date of when this Verification Request Feature Flag record was last updated. + tests: + - not_null + + - name: dwh_extracted_at_utc + data_type: timestamp + description: | + Timestamp of when this Verification Request Feature Flag record was extracted into DWH. diff --git a/models/staging/core/stg_core__verification_request_feature_flag.sql b/models/staging/core/stg_core__verification_request_feature_flag.sql new file mode 100644 index 0000000..5c5e451 --- /dev/null +++ b/models/staging/core/stg_core__verification_request_feature_flag.sql @@ -0,0 +1,33 @@ +{{ + config( + materialized="incremental", + unique_key="id_verification_request_feature_flag", + ) +}} + + +with + raw_verification_request_feature_flag as ( + select * from {{ source("core", "VerificationRequestFeatureFlag") }} + ), + stg_core__verification_request_feature_flag as ( + select + {{ adapter.quote("Id") }} as id_verification_request_feature_flag, + {{ adapter.quote("VerificationRequestId") }} as id_verification_request, + {{ adapter.quote("Name") }} as feature_flag_name, + {{ adapter.quote("State") }} as feature_flag_variation, + {{ adapter.quote("IsEnabled") }} as is_feature_flag_enabled, + {{ 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_feature_flag + ) +select * +from stg_core__verification_request_feature_flag +{% if is_incremental() %} + where + updated_at_utc + >= ((select max(updated_at_utc) from {{ this }}) - interval '7 days') +{% endif %}