Skip to content
Back to skills

Spark

ASecurity

Build Spark DataFrame and SQL jobs, tune partitions and shuffle behavior, and diagnose local or cluster execution failures.

  • 2 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added October 22, 2026
ai-agentspythongosqlnodeapi

Works with

  • cursor
  • api

Security analysis

A100/100

Scanned October 22, 2026

npx -y skills add alivirgo/Major-AI-Skills --skill spark --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Spark?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Spark
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/alivirgo-spark/badge)](https://www.skillsdirectory.com/skills/alivirgo-spark)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: spark
description: "Build Spark DataFrame and SQL jobs, tune partitions and shuffle behavior, and diagnose local or cluster execution failures."
category: scientific
risk: safe
source: self
source_type: self
date_added: "2026-08-26"
tags: ["spark", "pyspark", "dataframe", "big-data", "sql", "claude"]
tools: ["claude", "cursor", "gemini", "codex"]
---

# Apache Spark AI Skill Guide

## Overview & Engine Architecture

Spark distributes DataFrame/Dataset work across executors. Transformations build a lineage; actions (`count`, `write`) trigger jobs split into stages at shuffle boundaries. Agents design partition keys, avoid wide shuffles, cache only reused hot datasets, and read Spark UI / explain plans before throwing more cores at a bad query.

```
Driver (SparkSession)
   -> jobs / stages / tasks
        -> executors (partitions)
             -> shuffle / reduce
             -> sink (Parquet, table)
```

## When to use this skill

- Multi-node ETL beyond single-machine Polars/DuckDB
- Lakehouse table transforms (Parquet/Delta/Iceberg via connectors)
- Spark SQL shared with analytics engineers

## Operational directives

1. Prefer DataFrame API / Spark SQL over RDDs for optimizer benefits.
2. Repartition or bucket on join/group keys intentionally; do not `repartition(200)` blindly.
3. Filter and project before joins.
4. Treat `collect()` to the driver as a bug on large results.
5. Size AQE / broadcast hints with measured data, not folklore.

## PySpark transform example

```python
from pyspark.sql import SparkSession, functions as F

spark = SparkSession.builder.appName("orders-mart").getOrCreate()

orders = spark.read.parquet("s3a://lake/orders/")
daily = (
    orders
    .where(F.col("created_at") >= "2025-01-01")
    .groupBy(F.to_date("created_at").alias("day"), "customer_id")
    .agg(F.sum("amount").alias("revenue"), F.count("*").alias("orders"))
)

daily.write.mode("overwrite").parquet("s3a://lake/marts/daily_revenue/")
```

## Diagnose skew

```python
daily.explain(extended=True)
# Spark UI: Stages -> look for long-tail tasks / spill
```

## Common failures

| Symptom | Cause | Fix |
| --- | --- | --- |
| Shuffle spill | uneven keys / wide join | salt keys; broadcast small side |
| Driver OOM | `.collect` / huge broadcast | write out; sample |
| Tiny files | too many partitions on write | `coalesce` / maxRecordsPerFile |
| Slow job | UDF per row | built-in functions / Pandas UDFs carefully |

## Best practices

- Idempotent writes to dated paths or transactional tables.
- Persist (`cache`) only multi-action reuse; then `unpersist`.
- Align partition columns with filter patterns (`dt=YYYY-MM-DD`).
- Pin Spark + connector versions with the cluster runtime.

## Limitations

- Local mode is for unit tests, not production scale claims.
- Streaming Structured Streaming needs separate checkpoint design.
- Cloud IAM/storage credentials are environment-specific.

## Related skills

- `@duckdb` / `@polars` - single-node alternatives
- `@airflow` / `@prefect` - schedule Spark jobs
- `@dbt` - SQL models on Spark/Databricks SQL warehouses

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.