| Title | Reference | Author | Source Branch | Dest Branch | |
|---|---|---|---|---|---|
| Bump gitlab-ci docker image, remove test deps from container. | repos/data-engineering/mediawiki-content-pipelines!61 | xcollazo | clean-up-gitlab-ci | main |
Details
| Status | Subtype | Assigned | Task | ||
|---|---|---|---|---|---|
| Open | None | T366752 Dumps 2.0 Phase III: Production level dumps (SDS 1.2) | |||
| Resolved | xcollazo | T391279 Daily updated wmf_content.mediawiki_content_current_v1 | |||
| Resolved | xcollazo | T391282 Create table and pyspark job to produce wmf_content.mediawiki_content_current_v1 |
Event Timeline
xcollazo updated https://gitlab.wikimedia.org/repos/data-engineering/dumps/mediawiki-content-dump/-/merge_requests/61
Bump gitlab-ci docker image, remove test deps from container.
xcollazo merged https://gitlab.wikimedia.org/repos/data-engineering/dumps/mediawiki-content-dump/-/merge_requests/61
Bump gitlab-ci docker image, remove test deps from container.
xcollazo opened https://gitlab.wikimedia.org/repos/data-engineering/dumps/mediawiki-content-dump/-/merge_requests/62
Draft: Implement MERGE INTO script for mediawiki_content_current_v1
From MR 62:
In this MR we:
- Define DDL for wmf_content.mediawiki_content_current_v1. Over at source table wmf_content.mediawiki_content_history_v1, we have 3 control columns. For this table we only need one control column, row_update_dt, as we consume changes from the one source. See the control column's usage in code for details on why this is needed.
- We implement a MERGE INTO pyspark job to gather per page changes from the source table, and apply them to the target. We tried a few tricks, like dataframe caching to accelerate change detection, but found out we got little or no benefit while making the code more complicated, thus opted to eliminate that code.
- Were we did find benefit is on doing a BROADCAST of the detected changes when doing the full table scan on the source table. For this, we include a flag to toggle between BROADCAST and MERGE join strategies. The calculated changes dataframe is about ~1M changes (~200MBs) for a typical daily ingestion, but we want to have the option to do a MERGE join in case we need to catchup multiple days and for backfills.
- As per Spike T366544, The MERGE statement requires no state, and is self-healing; if we failed a daily run, we can ignore and rerun it later and we will pick up all changes.
xcollazo merged https://gitlab.wikimedia.org/repos/data-engineering/dumps/mediawiki-content-dump/-/merge_requests/62
Implement pipeline for mediawiki_content_current_v1
Ran the following:
hostname -f
an-launcher1002.eqiad.wmnet
sudo -u analytics bash
kerberos-run-command analytics spark3-sql
CREATE TABLE wmf_content.mediawiki_content_current_v1 (
page_id BIGINT COMMENT 'The (database) page ID of the page.',
page_namespace_id INT COMMENT 'The id of the namespace this page belongs to.',
page_title STRING COMMENT 'The normalized title of the page. If page_namespace_id = 0, then this is the non namespaced title. If page_namespace_id != 0, then the title is prepended with the localized namespace. Examples for "enwiki": "Main_Page" and "Talk:Main_Page".',
page_redirect_target STRING COMMENT 'title of the redirected-to page, if any. Same rules as page_title.',
user_id BIGINT COMMENT 'id of the user that made the revision; null if anonymous, zero if old system user, and -1 when deleted or malformed XML was imported',
user_text STRING COMMENT 'text of the user that made the revision (either username or IP)',
user_is_visible BOOLEAN COMMENT 'Whether the user that made the revision is visible. If this is false, then the user should be redacted when shown publicly. See RevisionRecord->DELETED_USER.',
revision_id BIGINT COMMENT 'The (database) revision ID.',
revision_parent_id BIGINT COMMENT 'The (database) revision ID. of the parent revision',
revision_dt TIMESTAMP COMMENT 'The (database) time this revision was created. This is rev_timestamp in the MediaWiki database.',
revision_is_minor_edit BOOLEAN COMMENT 'True if the editor marked this revision as a minor edit.',
revision_comment STRING COMMENT 'The comment left by the user when this revision was made.',
revision_comment_is_visible BOOLEAN COMMENT 'Whether the comment of the revision is visible. If this is false, then the comment should be redacted when shown publicly. See RevisionRecord->DELETED_COMMENT.',
revision_sha1 STRING COMMENT 'Nested SHA1 hash of hashes of all content slots. See https://www.mediawiki.org/wiki/Manual:Revision_table#rev_sha1',
revision_size BIGINT COMMENT 'the sum of the content_size of all content slots',
revision_content_slots MAP<
STRING,
STRUCT<content_body: STRING,
content_format: STRING,
content_model: STRING,
content_sha1: STRING,
content_size: BIGINT
>
> COMMENT 'a MAP containing all the content slots associated to this revision. Typically just the "main" slot, but also "mediainfo" for commonswiki.',
revision_content_is_visible BOOLEAN COMMENT 'Whether revision_content_slots is visible. If this is false, then any content should be redacted when shown publicly. See RevisionRecord->DELETED_TEXT.',
wiki_id STRING COMMENT 'The wiki ID, which is usually the same as the MediaWiki database name. E.g. enwiki, metawiki, etc.',
row_update_dt TIMESTAMP COMMENT 'Control column to efficiently update this table from source at wmf_content.mediawiki_content_history_v1.'
)
USING ICEBERG
PARTITIONED BY (wiki_id) -- wiki_id partitioning is familiar to users
TBLPROPERTIES (
'format-version' = '2', -- allow merge-on-read
'write.merge.mode' = 'merge-on-read', -- enable merge-on-read when doing MERGE INTO
'write.format.default' = 'parquet', -- parquet is currently the only format with min/max stats
'write.target-file-size-bytes' = '134217728' -- cap files at 128MB files so executors with 1 core, 16GB RAM can read the entire table
)
COMMENT 'Contains the latest revision for all pages for all wikis. Updated on a daily basis.'
LOCATION 'hdfs://analytics-hadoop/wmf/data/wmf_content/mediawiki_content_current_v1'
;
`Mentioned in SAL (#wikimedia-analytics) [2025-04-23T19:19:16Z] <xcollazo> CREATEd table wmf_content.mediawiki_content_current_v1. T391282.
Backfilled the table via:
hostname -f an-launcher1002.eqiad.wmnet sudo -u analytics bash kerberos-run-command analytics spark3-sql \ --driver-cores 4 \ --master yarn \ --conf spark.driver.maxResultSize=8G \ --conf spark.dynamicAllocation.maxExecutors=64 \ --conf spark.sql.shuffle.partitions=10240 \ --conf spark.sql.iceberg.locality.enabled=true \ --executor-cores 2 \ --executor-memory 32G \ --driver-memory 16G \ --name xcollazo_backfill_mw_content_merge_changes_to_mw_content_current_daily INSERT INTO wmf_content.mediawiki_content_current_v1 SELECT * FROM xcollazo.mediawiki_content_current_v2 ORDER BY wiki_id;
Took 11.3h (Spark History), most of the time just swapping out to disk when doing the sort on 3 tasks, likely commonswiki, wikidatawiki and enwiki. This of course could be optimized by INSERTing those 3 wikis separately, but I ran this overnight, there was no incentive to do anything fancier.
All done here, table now available in the data lake wmf_content.mediawiki_content_current_v1.