/data-engineering-skills:optimizing-pyspark-jobsfrom data-engineering-skills
Optimizes slow or failing PySpark and Spark SQL jobs by addressing partitioning, data skew, shuffles, broadcast joins, caching, Adaptive Query Execution, and avoiding driver collects and Python UDFs.
Ships in data-engineering-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
optimizing-sql-queries).- [ ] Read the Spark UI: find the slow stage and its shuffle/skew
- [ ] Confirm the cause: skew, too many/few partitions, wide shuffle, or driver pull
- [ ] Fix joins (broadcast small side; salt skewed keys)
- [ ] Right-size partitions; enable AQE
- [ ] Re-run and compare stage time/shuffle bytes
Broadcast the small side to avoid a shuffle join:
from pyspark.sql.functions import broadcast
fact.join(broadcast(small_dim), "dim_id")
Enable Adaptive Query Execution (coalesces partitions, converts to broadcast, handles skew automatically):
spark.conf.set("spark.sql.adaptive.enabled", "true")
spark.conf.set("spark.sql.adaptive.skewJoin.enabled", "true")
Salt a skewed join key when one key value dominates (AQE off or extreme skew): add a random suffix to the hot key on both sides so it spreads across tasks.
Right-size partitions — aim for ~128MB per partition. Use repartition(n) to
increase parallelism before a wide operation; use coalesce(n) to reduce small
output files without a shuffle.
Cache only reused DataFrames, and unpersist when done:
df.cache(); df.count() # materialize once if used multiple times
...
df.unpersist()
collect() / toPandas() on large data — pulls everything to the driver
and OOMs it. Aggregate first, or write to storage.spark.sql.shuffle.partitions to fit the data.repartition() when coalesce() suffices — repartition forces a full
shuffle; use coalesce to only shrink partition count.coalesce before write or use adaptive
file sizing.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
pyspark, spark-sql, performance-tuning, data-skew, shuffle-optimization
npx claudepluginhub unknown-333/awesome-data-engineering-skills --plugin data-engineering-skills36 skills in this plugin
/authoring-airflow-dagsWrite production-grade Apache Airflow DAGs using the TaskFlow API — idempotent tasks, correct scheduling and catchup, retries/SLAs, connections/variables, and avoiding top-level code. Use when creating or reviewing Airflow DAGs, scheduling pipelines, wiring task dependencies, configuring retries/backfills, or fixing non-idempotent tasks./building-dagster-assetsBuild Dagster pipelines using software-defined assets — asset dependencies, partitions, resources and IO managers, asset checks, and schedules/sensors. Use when creating Dagster assets or jobs, modeling data as assets, adding partitions or backfills, wiring resources/IO managers, or migrating from task-based orchestration to assets./Other plugins' skills for the same job