Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion bigquery_etl/shredder/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ def fields(self) -> tuple[str, ...]:
CLIENT_ID = "client_id"
GLEAN_CLIENT_ID = "client_info.client_id"
GLEAN_USAGE_PROFILE_ID = "metrics.uuid.usage_profile_id"
USAGE_PROFILE_ID = "usage_profile_id"
IMPRESSION_ID = "impression_id"
USER_ID = "user_id"
POCKET_ID = "pocket_id"
Expand Down Expand Up @@ -214,6 +215,7 @@ def fields(self) -> tuple[str, ...]:


client_id_target = partial(DeleteTarget, field=CLIENT_ID)
usage_profile_id_target = partial(DeleteTarget, field=USAGE_PROFILE_ID)
glean_target = partial(DeleteTarget, field=GLEAN_CLIENT_ID)
impression_id_target = partial(DeleteTarget, field=IMPRESSION_ID)
fxa_user_id_target = partial(DeleteTarget, field=FXA_USER_ID)
Expand Down Expand Up @@ -901,7 +903,7 @@ def stable_tables_by_schema(schema_id):
metric_type_field.name == "uuid"
and any(
[
metric_field.name == "usage_profile_id"
metric_field.name == USAGE_PROFILE_ID
for metric_field in metric_type_field.fields
]
)
Expand Down Expand Up @@ -974,6 +976,18 @@ def stable_tables_by_schema(schema_id):
if table.table_id == "usage_reporting_v1"
and table.dataset_id in usage_reporting_sources
},
**{
# usage_reporting derived tables that contain usage_profile_id
DeleteTarget(
table=qualified_table_id(table),
# field must be repeated for each deletion source
field=(USAGE_PROFILE_ID,) * len(sources[table.dataset_id]),
): sources[table.dataset_id]
for table in glean_derived_tables
if any(field.name == USAGE_PROFILE_ID for field in table.schema)
and not table.table_id.startswith(derived_source_prefix)
and qualified_table_id(table) not in skipped_tables
},
}


Expand Down
26 changes: 26 additions & 0 deletions tests/shredder/test_config.py
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not actually sure this test_config does anything or if these changes are even needed / useful.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The derived tables need to be added to the FakeClient in this file. This should be tested since it's easy to get wrong (as it is now)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just took a closer look at the tests and the setup isn't trivial so I can update the tests if you don't want to do it

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, please. That would be nice. I'm finding this test suite quite confusing. I'd be happy to pair on it otherwise a walk-through of what needed to be updated would also be nice.

Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ def get_table(self, table_ref):
"focus_android",
}:
table.schema = [bigquery.SchemaField("client_id", "STRING")]
elif table.table_id in {
"usage_reporting_clients_daily_v1",
}:
table.schema = [bigquery.SchemaField("usage_profile_id", "STRING")]
else:
table.schema = [bigquery.SchemaField("document_id", "STRING")]
return table
Expand Down Expand Up @@ -292,6 +296,28 @@ def test_glean_targets(mock_requests):
),
]
},
**{
target: { # usage_reporting
DeleteSource(
table="org_mozilla_focus_stable.usage_deletion_request_v1",
field="metrics.uuid.usage_profile_id",
project="moz-fx-data-shared-prod",
conditions=(),
),
}
for target in [
DeleteTarget(
table="org_mozilla_focus_stable.usage_reporting_v1",
field=("metrics.uuid.usage_profile_id",) * 2,
project="moz-fx-data-shared-prod",
),
DeleteTarget(
table="focus_android_derived.usage_reporting_clients_daily_v1",
field=("usage_profile_id",) * 2,
project="moz-fx-data-shared-prod",
),
]
},
}


Expand Down