Merged PR 3047: Override migration date with join date if join date is after migration date
# Description Quick fix to make lower_limit_migration_date_utc more robust for new dash reporting purposes. I noticed some cases in which users were actually created after the migration date. In these cases, I just keep joined date. # 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. - [ ] I have checked for DRY opportunities with other models and docs. - [ ] 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: #22331
This commit is contained in:
parent
28c554de63
commit
3480d4d787
2 changed files with 25 additions and 5 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
{{ config(materialized="table") }}
|
{{ config(materialized="table") }}
|
||||||
with
|
with
|
||||||
stg_core__claim as (select * from {{ ref("stg_core__claim") }}),
|
stg_core__claim as (select * from {{ ref("stg_core__claim") }}),
|
||||||
|
stg_core__user as (select * from {{ ref("stg_core__user") }}),
|
||||||
|
|
||||||
user_migration_from_claim as (
|
user_migration_from_claim as (
|
||||||
select
|
select
|
||||||
|
|
@ -56,11 +57,18 @@ with
|
||||||
-- the date corresponding to the claim with more priority will be selected. The lower
|
-- the date corresponding to the claim with more priority will be selected. The lower
|
||||||
-- the claim_enforcement_priority, the more priority it will have. If still 2 claims
|
-- the claim_enforcement_priority, the more priority it will have. If still 2 claims
|
||||||
-- have the same priority, select the earliest date.
|
-- have the same priority, select the earliest date.
|
||||||
|
-- Lastly, the migrated date is overridden with the user joined date only if the user
|
||||||
|
-- was actually created after the expected migration date.
|
||||||
select
|
select
|
||||||
id_user_host,
|
c.id_user_host,
|
||||||
migration_phase,
|
c.migration_phase,
|
||||||
lower_limit_migration_date_utc,
|
greatest(
|
||||||
claim_enforcement_priority
|
c.lower_limit_migration_date_utc, u.joined_date_utc
|
||||||
|
) as lower_limit_migration_date_utc,
|
||||||
|
c.claim_enforcement_priority,
|
||||||
|
case
|
||||||
|
when u.joined_date_utc > c.lower_limit_migration_date_utc then true else false
|
||||||
|
end as is_overridden_with_joined_date
|
||||||
from
|
from
|
||||||
(
|
(
|
||||||
select
|
select
|
||||||
|
|
@ -74,5 +82,6 @@ from
|
||||||
claim_enforcement_priority asc, lower_limit_migration_date_utc asc
|
claim_enforcement_priority asc, lower_limit_migration_date_utc asc
|
||||||
) as rank
|
) as rank
|
||||||
from user_migration_from_claim
|
from user_migration_from_claim
|
||||||
)
|
) c
|
||||||
|
inner join stg_core__user u on c.id_user_host = u.id_user
|
||||||
where rank = 1
|
where rank = 1
|
||||||
|
|
|
||||||
|
|
@ -2528,6 +2528,17 @@ models:
|
||||||
this date.
|
this date.
|
||||||
tests:
|
tests:
|
||||||
- not_null
|
- not_null
|
||||||
|
- name: claim_enforcement_priority
|
||||||
|
data_type: integer
|
||||||
|
description: |
|
||||||
|
Informative field. It just states which claim enforcement priority
|
||||||
|
has been used for the computation.
|
||||||
|
- name: is_overridden_with_joined_date
|
||||||
|
data_type: boolean
|
||||||
|
description: |
|
||||||
|
Informative field. Boolean to indicate if the expected migration date
|
||||||
|
based in the logic is finally overridden with the user joined date
|
||||||
|
in case the user was created after the expected migration date.
|
||||||
|
|
||||||
- name: int_core__address_validations
|
- name: int_core__address_validations
|
||||||
description:
|
description:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue