Page MenuHomePhabricator

data-reload: spark processing jobs need to be orchestrated in the wikidata dag.
Closed, ResolvedPublic5 Estimated Story Points

Description

In order to generate split graphs from the ttl dump, we need to orchestrate spark jobs for data preparation and transfer.
Ultimately we need to generate snapshots in n3 format that will be ingested by the T428235: [NEEDS GROOMING] data-reload: create a QLever index using an ephemeral instance.

The following WDQS v1 steps needs to be implemented in the WDQS v2 data pipeline (airflow dag).

munge_dumps can read the ttl file we generate (on k8s) from S3, and store its output in HDFS for it's children task to pickup.
The output of export_n3 should be store both on HDFS / Hive for analytics, as well as S3 for exposing it to the qlever-indexer file.

Modulo changes in input / output paths and tables that need to be stored in the wikidata database, not business logic changes are expected. We need to benchmark i/o perf when reading/writing for s3.

Spark execution

Ideally we want to execute the spark workload on k8s, but a first iteration would work fine on hadoop (hdfs and hive metastore). We want to decouple the business logic (our spark jobs and hive tables) from the execution infra (hadoop or k8s and the respective airflow operators).

This approach might require some sync with DE (cc @JAllemandou @Ahoelzl ) since AFAIK we don't have any workflow writing to s3 from hadoop yet.

Spark (Hadoop) has been tested and hadoop workers can access s3. We can start implementing with the current hadoop target, and swap for spark-on-k8s when ready.

@JAllemandou I tested interactively with a dummy job:

from pyspark.sql import SparkSession

spark = SparkSession.builder \
    .appName("s3-connectivity-test") \
    .getOrCreate()

data = [("hello", 1), ("world", 2)]
df = spark.createDataFrame(data, ["word", "count"])

df.write \
    .mode("overwrite") \
    .parquet("s3a://gmodena-test-bucket.dse-k8s-eqiad/spark-out")

print("Write succeeded!")
spark.stop()

Launched with

spark3-submit -v \
  --jars hadoop-aws-3.2.0.jar,aws-java-sdk-bundle-1.11.888.jar \
  --conf "spark.hadoop.fs.s3a.endpoint=rgw.eqiad.dpe.anycast.wmnet" \
  --conf "spark.hadoop.fs.s3a.access.key=${s3_access_key}" \
  --conf "spark.hadoop.fs.s3a.secret.key=${s3_secret_key}" \
  --conf "spark.hadoop.fs.s3a.path.style.access=true" \
  --conf "spark.hadoop.fs.s3a.impl=org.apache.hadoop.fs.s3a.S3AFileSystem" \
  s3_test.py

This bring in dependencies on hadoop-aws-3.2.0.jar,aws-java-sdk-bundle-1.11.888.jar, but they are Apache 2 licensed and available in maven central.

We have s3 credentials already available in k8s and airflow (via a connection setting), but we might need to patch the ApacheSparkSubmitOperator to pick them up (or provide custom properties). If you are comfortable with this direction we can pick up the work.

Details

Related Changes in GitLab:
TitleReferenceAuthorSource BranchDest Branch
wikidata: orchestrate spark jobs for data preparation and transfer.repos/data-engineering/airflow-dags!2319gmodenawikidata-process-ttl-cleanedmain
Customize query in GitLab

Event Timeline

Thanks a lot for the clear task definition @gmodena :)

It's great if your team starts working in the direction you describe, with updates to the Airflow SparkSubmitOperator. Note that we already have a Saprk operator wrapper, where I think the integration work probably should be done.

Also, let's ask @BTullis if he can make the new needed jars available for us in a our hadoop libs maybe? My assumption is that it's on the critical path to make Hive tables be able to read from s3 (T425673: Enable Ceph S3 locations for Hive Metastore tables).

Also, let's ask @BTullis if he can make the new needed jars available for us in a our hadoop libs maybe? My assumption is that it's on the critical path to make Hive tables be able to read from s3 (T425673: Enable Ceph S3 locations for Hive Metastore tables).

FWIW: for this first iteration I don't think we need s3 table support. We can keep everything in HDFS and copy only the output files (export_n3) into S3.

gmodena renamed this task from [NEEDS GROOMING] data-reload: spark processing jobs need to be orchestrated in the wikidata dag. to data-reload: spark processing jobs need to be orchestrated in the wikidata dag..Jun 16 2026, 12:33 PM
gmodena claimed this task.
gmodena triaged this task as Medium priority.
gmodena set the point value for this task to 5.