Skip to content

Commit 3a9bb67

Browse files
committed
refactor(benefits): coalesce enrollment_group props
deprecate old cols in mart definition
1 parent d73c7f0 commit 3a9bb67

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

warehouse/models/mart/benefits/_mart_benefits.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,13 @@ models:
8484
- name: event_properties_path
8585
description: The `path` value from the `event_properties` column
8686
- name: event_properties_payment_group
87-
description: The `payment_group` value from the `event_properties` column
87+
description: The `enrollment_group` value from the `event_properties` column
88+
deprecated:
89+
enabled: true
90+
reason: "This column is deprecated, use `event_properties_enrollment_group` instead"
91+
date: "2024-10-10"
92+
- name: event_properties_enrollment_group
93+
description: The `enrollment_group` value from the `event_properties` column
8894
- name: event_properties_status
8995
description: The `status` value from the `event_properties` column
9096
- name: event_properties_transit_agency

warehouse/models/mart/benefits/fct_benefits_events.sql

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ WITH fct_benefits_events AS (
4444
{{ json_extract_column('event_properties', 'language') }},
4545
{{ json_extract_column('event_properties', 'origin') }},
4646
{{ json_extract_column('event_properties', 'path') }},
47-
{{ json_extract_column('event_properties', 'payment_group') }},
4847
{{ json_extract_column('event_properties', 'status') }},
4948
{{ json_extract_column('event_properties', 'transit_agency') }},
5049

@@ -66,6 +65,15 @@ WITH fct_benefits_events AS (
6665
-- include the old field as well, deprecated in the mart definition
6766
event_properties_enrollment_flows AS event_properties_eligibility_types,
6867

68+
-- Historical data existed in `payment_group` but new data is in `enrollment_group`
69+
-- https://github.com/cal-itp/benefits/pull/2391
70+
COALESCE(
71+
{{ json_extract_flattened_column('event_properties', 'enrollment_group', no_alias = true) }},
72+
{{ json_extract_flattened_column('event_properties', 'payment_group', no_alias = true) }}
73+
) AS event_properties_enrollment_group,
74+
-- include the old field as well, deprecated in the mart definition
75+
event_properties_enrollment_group AS event_properties_payment_group,
76+
6977
-- User Properties (https://app.amplitude.com/data/compiler/Benefits/properties/main/latest/user)
7078
{{ json_extract_column('user_properties', 'eligibility_verifier') }},
7179
{{ json_extract_column('user_properties', 'initial_referrer') }},
@@ -142,7 +150,8 @@ fct_old_enrollments AS (
142150
event_properties_language,
143151
event_properties_origin,
144152
event_properties_path,
145-
"5170d37b-43d5-4049-899c-b4d850e14990" as event_properties_payment_group,
153+
"5170d37b-43d5-4049-899c-b4d850e14990" as event_properties_enrollment_group,
154+
event_properties_enrollment_group as event_properties_payment_group,
146155
"success" as event_properties_status,
147156
"Monterey-Salinas Transit" as event_properties_transit_agency,
148157
"senior" as event_properties_enrollment_flows,

0 commit comments

Comments
 (0)