Skip to content

Commit

Permalink
DENG-1879 Setup import of emails table from FxA prod CloudSQL (#4494)
Browse files Browse the repository at this point in the history
  • Loading branch information
akkomar authored Oct 31, 2023
1 parent 511894d commit 2754d7d
Show file tree
Hide file tree
Showing 5 changed files with 89 additions and 0 deletions.
1 change: 1 addition & 0 deletions bqetl_project.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ dry_run:
- sql/moz-fx-data-shared-prod/accounts_backend_external/nonprod_emails_v1/query.sql
- sql/moz-fx-data-shared-prod/accounts_backend/nonprod_accounts/view.sql
- sql/moz-fx-data-shared-prod/accounts_backend_external/accounts_v1/query.sql
- sql/moz-fx-data-shared-prod/accounts_backend_external/emails_v1/query.sql
- sql/moz-fx-data-shared-prod/accounts_backend/accounts/view.sql
- sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_content_events_v1/query.sql
- sql/moz-fx-data-shared-prod/firefox_accounts_derived/fxa_auth_bounce_events_v1/query.sql
Expand Down
12 changes: 12 additions & 0 deletions dags/bqetl_accounts_backend_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@
task_concurrency=1,
)

accounts_backend_external__emails__v1 = bigquery_etl_query(
task_id="accounts_backend_external__emails__v1",
destination_table="emails_v1",
dataset_id="accounts_backend_external",
project_id="moz-fx-data-shared-prod",
owner="akomar@mozilla.com",
email=["akomar@mozilla.com", "telemetry-alerts@mozilla.com"],
date_partition_parameter=None,
depends_on_past=False,
task_concurrency=1,
)

accounts_backend_external__nonprod_accounts__v1 = bigquery_etl_query(
task_id="accounts_backend_external__nonprod_accounts__v1",
destination_table="nonprod_accounts_v1",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
friendly_name: Emails table from production FxA database
description: |-
A mirror of the `emails` table from the production FxA CloudSQL database,
updated daily to match the current state of the table.
Some fields in this table are converted to a more user-friendly, BigQuery-native format:
- `uid` is converted from bytes to a hex string
- boolean integer columns are converted to BOOL
- timestamp columns are converted to TIMESTAMP
See https://mozilla.github.io/ecosystem-platform/reference/database-structure#database-fxa
owners:
- akomar@mozilla.com
labels:
application: accounts_backend
schedule: daily
scheduling:
dag_name: bqetl_accounts_backend_external
# destination is the whole table, not a single partition,
# so don't use date_partition_parameter
date_partition_parameter: null
referenced_tables: []
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
SELECT
id,
normalizedEmail,
email,
TO_HEX(uid) AS uid,
SAFE_CAST(isVerified AS BOOL) AS isVerified,
SAFE_CAST(isPrimary AS BOOL) AS isPrimary,
SAFE.TIMESTAMP_MILLIS(SAFE_CAST(verifiedAt AS INT)) AS verifiedAt,
SAFE.TIMESTAMP_MILLIS(SAFE_CAST(createdAt AS INT)) AS createdAt,
FROM
EXTERNAL_QUERY(
"moz-fx-fxa-prod.us.fxa-rds-prod-prod-fxa",
"""SELECT
id,
normalizedEmail,
email,
uid,
isVerified,
isPrimary,
verifiedAt,
createdAt
FROM
emails
"""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
fields:
- name: id
type: INTEGER
mode: NULLABLE
- name: normalizedEmail
type: STRING
mode: NULLABLE
- name: email
type: STRING
mode: NULLABLE
- name: uid
type: STRING
mode: NULLABLE
description: |-
Account ID in hexadecimal format.
FxA stores this as bytes, for purposes of logging or integration
with other systems we convert it to a hex string.
- name: isVerified
type: BOOLEAN
mode: NULLABLE
- name: isPrimary
type: BOOLEAN
mode: NULLABLE
- name: verifiedAt
type: TIMESTAMP
mode: NULLABLE
- name: createdAt
type: TIMESTAMP
mode: NULLABLE

0 comments on commit 2754d7d

Please sign in to comment.