Skip to content

Commit f348e3d

Browse files
committed
Update table names in DeleteTarget configurations
1 parent b956508 commit f348e3d

File tree

5 files changed

+91
-12
lines changed

5 files changed

+91
-12
lines changed

bigquery_etl/shredder/config.py

Lines changed: 7 additions & 12 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,
@@ -704,21 +707,13 @@ def fields(self) -> tuple[str, ...]:
704707
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
705708
): EXPERIMENTER_BACKEND_SRC,
706709
DeleteTarget(
707-
table="accounts_cirrus_stable.enrollment_v1",
708-
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
709-
): FXA_UNHASHED_SRC,
710-
DeleteTarget(
711-
table="accounts_cirrus_stable.enrollment_status_v1",
712-
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
713-
): FXA_UNHASHED_SRC,
714-
DeleteTarget(
715-
table="subplat_cirrus_stable.enrollment_v1",
710+
table="subscription_platform_backend_cirrus_stable.enrollment_v1",
716711
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
717-
): FXA_UNHASHED_SRC,
712+
): SUBPLAT_CIRRUS_SRC,
718713
DeleteTarget(
719-
table="subplat_cirrus_stable.enrollment_status_v1",
714+
table="subscription_platform_backend_cirrus_stable.enrollment_status_v1",
720715
field=CIRRUS_EVENTS_NIMBUS_USER_ID,
721-
): FXA_UNHASHED_SRC,
716+
): SUBPLAT_CIRRUS_SRC,
722717
}
723718

724719
SEARCH_IGNORE_TABLES = {source.table for source in SOURCES}
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+
delete_events.submission_timestamp,
46+
uuid_v5(delete_events.user_id_unhashed, subplat_namespaces.namespace) AS nimbus_user_id,
47+
FROM
48+
`moz-fx-data-shared-prod.firefox_accounts.delete_events` AS delete_events
49+
CROSS JOIN
50+
subplat_namespaces
51+
WHERE
52+
DATE(delete_events.submission_timestamp) = @submission_date
53+
AND 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

0 commit comments

Comments
 (0)