Skip to content

[DENG-11196] Port socorro import job from spark#9700

Draft
BenWu wants to merge 1 commit into
mainfrom
benwu/socorro-import
Draft

[DENG-11196] Port socorro import job from spark#9700
BenWu wants to merge 1 commit into
mainfrom
benwu/socorro-import

Conversation

@BenWu

@BenWu BenWu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Description

This ports the spark job at https://github.com/mozilla/telemetry-airflow/blob/3bdbe160fdf469e7630b8b87962a9c1883512be4/jobs/socorro_import_crash_data.py to a python script that loads the socorro_crash_v2 table. Output should be the same.

Depends on GCS permissions https://github.com/mozilla/webservices-infra/pull/11742

Related Tickets & Documents

Reviewer, please follow this checklist

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This PR ports the Socorro crash-report import from the Spark/Dataproc + parquet2bigquery pipeline to an in-repo query.py that runs a single BigQuery load into a temp table followed by a transform.sql that rewraps arrays and writes the crash_date partition. It adds README.md, query.py, transform.sql, and updates metadata.yaml.

The overall approach is clean — deriving the load schema from schema.yaml at runtime to keep it in sync, and using a temp table + transform to reproduce the Spark array-wrapping encoding is a reasonable design. My main concern is column ordering in transform.sql: writing to an existing partitioned table matches columns by position, so the EXCEPT-and-append reordering will likely fail the partition write, and the --dry-run path won't surface it because it sets no destination. Details inline.

-- the seven wrapped arrays and crash_date are rewritten explicitly.
SELECT
DATE("{crash_date}") AS crash_date,
* EXCEPT (additional_minidumps, addons, json_dump, memory_report),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

issue: This * EXCEPT (...) + append pattern reorders the output columns relative to schema.yaml. additional_minidumps (pos 9), addons (pos 10), json_dump, and memory_report are removed from their positions in the middle of the schema and re-emitted at the very end, while everything after them shifts up. BigQuery matches query results to an existing partitioned table (table$YYYYMMDD) by ordinal position, not by name, and a partition-decorator write cannot alter the table schema. So at the position where the table expects additional_minidumps (RECORD) the query now supplies addons_checked (BOOLEAN), and the write to the partition will fail with a schema mismatch.

Note this won't be caught by --dry-run: the dry-run QueryJobConfig sets no destination, so it validates the query in isolation and never compares against the destination table's column order.

Emit the columns in schema.yaml order — either rewrap each array in place instead of EXCEPT-and-append, or wrap the whole thing in an outer SELECT that projects the columns in the table's order.

Copy link
Copy Markdown
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 sure if this is true because we have a lot of ETL with non-matching schema order, but I'll test if I can get access to the source data.

Schema is based on https://github.com/mozilla-services/socorro/blob/main/socorro/schemas/telemetry_socorro_crash.json.

Differences from the upstream schema:
- `crash_date` (DATE, REQUIRED) is the partition column. It is not present in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nitpick: This says crash_date is (DATE, REQUIRED), but schema.yaml declares it mode: NULLABLE. Reconcile the two so the doc matches the schema (and, if the existing prod table has crash_date as REQUIRED, update schema.yaml to match to avoid a mode mismatch on schema deploy).

@BenWu
BenWu marked this pull request as draft July 15, 2026 21:50
@scholtzan

This comment has been minimized.

@BenWu
BenWu force-pushed the benwu/socorro-import branch from 40c7406 to 8060abf Compare July 16, 2026 18:40
@scholtzan

This comment has been minimized.

@BenWu
BenWu force-pushed the benwu/socorro-import branch from 8060abf to eaa9a8d Compare July 16, 2026 20:15
@scholtzan

Copy link
Copy Markdown
Collaborator

Integration report

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants