Skip to content

Commit 8ce2eca

Browse files
reludmikewilli
andauthored
chore(shredder): propagate fxa and subplat deletes to cirrus (#8401)
Co-authored-by: Mike Williams <[email protected]>
1 parent ff176ff commit 8ce2eca

File tree

7 files changed

+98
-0
lines changed

7 files changed

+98
-0
lines changed

bigquery_etl/shredder/config.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,9 @@ def fields(self) -> tuple[str, ...]:
151151
FXA_FRONTEND_GLEAN_SRC = DeleteSource(
152152
table="accounts_frontend_stable.deletion_request_v1", field=GLEAN_CLIENT_ID
153153
)
154+
SUBPLAT_CIRRUS_SRC = DeleteSource(
155+
table="subscription_platform_backend_cirrus.delete_events", field="nimbus_user_id"
156+
)
154157
EXPERIMENTER_BACKEND_SRC = DeleteSource(
155158
table="experimenter_backend_stable.data_collection_opt_out_v1",
156159
field=NIMBUS_USER_ID,
@@ -703,6 +706,14 @@ def fields(self) -> tuple[str, ...]:
703706
table="experimenter_cirrus_stable.enrollment_status_v1",
704707
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
705708
): EXPERIMENTER_BACKEND_SRC,
709+
DeleteTarget(
710+
table="subscription_platform_backend_cirrus_stable.enrollment_v1",
711+
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
712+
): SUBPLAT_CIRRUS_SRC,
713+
DeleteTarget(
714+
table="subscription_platform_backend_cirrus_stable.enrollment_status_v1",
715+
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
716+
): SUBPLAT_CIRRUS_SRC,
706717
}
707718

708719
SEARCH_IGNORE_TABLES = {source.table for source in SOURCES}

bqetl_project.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ dry_run:
5454
- sql/moz-fx-data-shared-prod/monitoring_derived/table_storage_v1/query.sql
5555
- sql/moz-fx-data-shared-prod/activity_stream/impression_stats_by_experiment/view.sql
5656
- sql/moz-fx-data-shared-prod/activity_stream/impression_stats_flat/view.sql
57+
- sql/moz-fx-data-shared-prod/subscription_platform_backend_cirrus_derived/delete_events_v1/query.sql
5758
# uses time travel, will error on dates prior to the time travel window
5859
- sql/moz-fx-data-shared-prod/accounts_backend_derived/monitoring_db_counts_v1/query.sql
5960
- sql/moz-fx-data-shared-prod/accounts_backend_derived/monitoring_db_recovery_phones_counts_v1/query.sql
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
CREATE OR REPLACE VIEW
2+
`moz-fx-data-shared-prod.subscription_platform_backend_cirrus.delete_events`
3+
AS
4+
SELECT
5+
*
6+
FROM
7+
`moz-fx-data-shared-prod.subscription_platform_backend_cirrus_derived.delete_events_v1`
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
friendly_name: Subscription Platform Backend Cirrus Delete Events
3+
description: Deletion events for subscription platform backend cirrus, derived
4+
from FxA's delete events and subplat's namespace secrets
5+
owners:
6+
7+
labels:
8+
incremental: true
9+
schedule: daily
10+
table_type: client_level
11+
scheduling:
12+
dag_name: bqetl_fxa_events
13+
bigquery:
14+
time_partitioning:
15+
type: day
16+
field: submission_timestamp
17+
require_partition_filter: false
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
CREATE TEMP FUNCTION format_uuid(value STRING)
2+
RETURNS STRING AS (
3+
CONCAT(
4+
SUBSTR(value, 1, 8),
5+
"-",
6+
SUBSTR(value, 9, 4),
7+
"-",
8+
SUBSTR(value, 13, 4),
9+
"-",
10+
SUBSTR(value, 17, 4),
11+
"-",
12+
SUBSTR(value, 21, 12)
13+
)
14+
);
15+
16+
CREATE TEMP FUNCTION uuid_v5(value STRING, namespace STRING)
17+
RETURNS STRING AS (
18+
FORMAT_UUID(
19+
TO_HEX(
20+
LEFT(
21+
SHA1(CONCAT(FROM_HEX(REPLACE(namespace, "-", "")), CAST(value AS BYTES FORMAT 'UTF8'))),
22+
16
23+
) --
24+
& FROM_HEX('ffffffffffff0fff3fffffffffffffff') --
25+
| FROM_HEX('00000000000050008000000000000000')
26+
)
27+
)
28+
);
29+
30+
WITH subplat_namespaces AS (
31+
SELECT
32+
CAST(
33+
AEAD.DECRYPT_BYTES(
34+
(SELECT keyset FROM `moz-fx-dataops-secrets.airflow_query_keys.subplat_namespaces_prod`),
35+
ciphertext,
36+
CAST(key_id AS BYTES)
37+
) AS STRING
38+
) AS namespace
39+
FROM
40+
`moz-fx-data-shared-prod.subscription_platform_derived.encrypted_keys_v1`
41+
WHERE
42+
key_id = 'subplat_namespaces_prod'
43+
)
44+
SELECT
45+
fxa_delete_events.submission_timestamp,
46+
uuid_v5(fxa_delete_events.user_id_unhashed, subplat_namespaces.namespace) AS nimbus_user_id,
47+
FROM
48+
`moz-fx-data-shared-prod.firefox_accounts.fxa_delete_events` AS fxa_delete_events
49+
CROSS JOIN
50+
subplat_namespaces
51+
WHERE
52+
DATE(fxa_delete_events.submission_timestamp) = @submission_date
53+
AND fxa_delete_events.user_id_unhashed IS NOT NULL
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fields:
2+
- name: submission_timestamp
3+
type: TIMESTAMP
4+
mode: NULLABLE
5+
- name: nimbus_user_id
6+
type: STRING
7+
mode: NULLABLE
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
friendly_name: Encrypted Keys V1
2+
description: Encrypted keys

0 commit comments

Comments
 (0)