spark-engineer
Skill này làm gì
Skill hướng dẫn AI viết và tinh chỉnh code Spark cho pipeline dữ liệu lớn và thiết lập cụm. Skill dành cho kỹ sư dữ liệu làm việc với tập dữ liệu lớn.
Khi nào nên dùng
- ✓Khi một job Spark chạy chậm và bạn cần tìm nguyên nhân.
- ✓Khi bạn viết các phép biến đổi DataFrame hoặc Spark SQL trên file lớn.
- ✓Khi bạn cần tinh chỉnh partition, join hoặc bộ nhớ executor cho cụm.
Liên kết skill
https://github.com/Jeffallan/claude-skills/blob/main/skills/spark-engineer/SKILL.mdSao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.
Cách dùng
Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.
Tin nhắn có sẵn để dán
Dành cho Claude Code, Codex hoặc Cursor: chạy lệnh trong thư mục dự án của bạn và skill sẽ được cài đặt.
Tải tệp SKILL.md về và thả vào thư mục skill của agent.
Ví dụ cách nhờ AI
“Bạn có thể giúp tôi tăng tốc job Spark này, vốn join hai bảng parquet lớn không?”
5 skill mới mỗi tuần. Đọc chỉ 1 phút.
Cách hoạt động
AI xem xét kế hoạch dữ liệu, viết các phép biến đổi, rồi kiểm tra Spark UI và số lượng partition để tìm và sửa điểm nghẽn.
Nội dung kỹ thuật (SKILL.md gốc)
Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.
Spark Engineer
Senior Apache Spark engineer specializing in high-performance distributed data processing, optimizing large-scale ETL pipelines, and building production-grade Spark applications.
Core Workflow
- Analyze requirements - Understand data volume, transformations, latency requirements, cluster resources
- Design pipeline - Choose DataFrame vs RDD, plan partitioning strategy, identify broadcast opportunities
- Implement - Write Spark code with optimized transformations, appropriate caching, proper error handling
- Optimize - Analyze Spark UI, tune shuffle partitions, eliminate skew, optimize joins and aggregations
- Validate - Check Spark UI for shuffle spill before proceeding; verify partition count with
df.rdd.getNumPartitions(); if spill or skew detected, return to step 4; test with production-scale data, monitor resource usage, verify performance targets
Reference Guide
Load detailed guidance based on context:
| Topic | Reference | Load When |
|---|---|---|
| Spark SQL & DataFrames | references/spark-sql-dataframes.md |
DataFrame API, Spark SQL, schemas, joins, aggregations |
| RDD Operations | references/rdd-operations.md |
Transformations, actions, pair RDDs, custom partitioners |
| Partitioning & Caching | references/partitioning-caching.md |
Data partitioning, persistence levels, broadcast variables |
| Performance Tuning | references/performance-tuning.md |
Configuration, memory tuning, shuffle optimization, skew handling |
| Streaming Patterns | references/streaming-patterns.md |
Structured Streaming, watermarks, stateful operations, sinks |
Code Examples
Quick-Start Mini-Pipeline (PySpark)
from pyspark.sql import SparkSession
from pyspark.sql import functions as F
from pyspark.sql.types import StructType, StructField, StringType, LongType, DoubleType
spark = SparkSession.builder \
.appName("example-pipeline") \
.config("spark.sql.shuffle.partitions", "400") \
.config("spark.sql.adaptive.enabled", "true") \
.getOrCreate()
# Always define explicit schemas in production
schema = StructType([
StructField("user_id", StringType(), False),
StructField("event_ts", LongType(), False),
StructField("amount", DoubleType(), True),
])
df = spark.read.schema(schema).parquet("s3://bucket/events/")
result = df \
.filter(F.col("amount").isNotNull()) \
.groupBy("user_id") \
.agg(F.sum("amount").alias("total_amount"), F.count("*").alias("event_count"))
# Verify partition count before writing
print(f"Partition count: {result.rdd.getNumPartitions()}")
result.write.mode("overwrite").parquet("s3://bucket/output/")
Broadcast Join (small dimension table < 200 MB)
from pyspark.sql.functions import broadcast
# Spark will automatically broadcast dim_table; hint makes intent explicit
enriched = large_fact_df.join(broadcast(dim_df), on="product_id", how="left")
Handling Data Skew with Salting
import pyspark.sql.functions as F
SALT_BUCKETS = 50
# Add salt to the skewed key on both sides
skewed_df = skewed_df.withColumn("salt", (F.rand() * SALT_BUCKETS).cast("int")) \
.withColumn("salted_key", F.concat(F.col("skewed_key"), F.lit("_"), F.col("salt")))
other_df = other_df.withColumn("salt", F.explode(F.array([F.lit(i) for i in range(SALT_BUCKETS)]))) \
.withColumn("salted_key", F.concat(F.col("skewed_key"), F.lit("_"), F.col("salt")))
result = skewed_df.join(other_df, on="salted_key", how="inner") \
.drop("salt", "salted_key")
Correct Caching Pattern
# Cache ONLY when the DataFrame is reused multiple times
df_cleaned = df.filter(...).withColumn(...).cache()
df_cleaned.count() # Materialize immediately; check Spark UI for spill
report_a = df_cleaned.groupBy("region").agg(...)
report_b = df_cleaned.groupBy("product").agg(...)
df_cleaned.unpersist() # Release when done
Constraints
MUST DO
- Use DataFrame API over RDD for structured data processing
- Define explicit schemas for production pipelines
- Partition data appropriately (200-1000 partitions per executor core)
- Cache intermediate results only when reused multiple times
- Use broadcast joins for small dimension tables (<200MB)
- Handle data skew with salting or custom partitioning
- Monitor Spark UI for shuffle, spill, and GC metrics
- Test with production-scale data volumes
MUST NOT DO
- Use collect() on large datasets (causes OOM)
- Skip schema
Câu hỏi thường gặp
Tôi có cần môi trường Spark để dùng không?
Có. Skill viết code cho ứng dụng Spark, nên bạn cần một môi trường Spark để chạy code đó.
Nó có xử lý được file .parquet không?
Có, skill bao quát xử lý file .parquet và phân vùng dữ liệu.
Nó chỉ bao quát DataFrame thôi sao?
Không. Nó cũng bao quát pipeline RDD và giúp bạn chọn giữa code DataFrame và RDD.
Chi tiết
Mô tả gốc của tác giả
Use when writing Spark jobs, debugging performance issues, or configuring cluster settings for Apache Spark applications, distributed data processing pipelines, or big data workloads. Invoke to write DataFrame transformations, optimize Spark SQL queries, implement RDD pipelines, tune shuffle operations, configure executor memory, process .parquet files, handle data partitioning, or build structured streaming analytics.
repo: Jeffallan/claude-skills
Độ phổ biến
- Sao GitHub
- 12k
- Vị trí xếp hạng
- #11457
- Giấy phép
- MIT
- Cập nhật
- 30/10/2026
Bình luận
- …
Thêm skill từ kho mã này
angular-architect
12kGiúp agent của bạn xây ứng dụng Angular 17 trở lên với standalone component, định tuyến lazy-loaded, state NgRx, mẫu RxJS và tinh chỉnh hiệu năng.
api-designer
12kGiúp agent của bạn thiết kế API REST hoặc GraphQL và viết đặc tả OpenAPI 3.1, với quy tắc cho tài nguyên, phân trang, định dạng lỗi và phiên bản.
architecture-designer
12kGiúp agent của bạn thiết kế kiến trúc hệ thống, so sánh các mẫu và công nghệ, và viết Architecture Decision Record giải thích từng lựa chọn.
atlassian-mcp
12kGiúp agent của bạn tìm kiếm và cập nhật issue Jira cùng trang Confluence qua MCP, gồm truy vấn JQL và CQL, sprint và đồng bộ tài liệu.
Skill tương tự
gitcrawl
394kCho phép agent của bạn tìm trong kho lưu trữ issue và pull request GitHub, gom các mục trùng lặp và kiểm tra trạng thái hiện tại trên GitHub.
slacrawl
394kCho phép agent của bạn tìm và đếm tin nhắn trong kho lưu trữ Slack cục bộ, kiểm tra kho đó mới đến mức nào và làm mới khi cần.
goplaces
394kGiúp agent của bạn tìm địa điểm, lấy chi tiết và đánh giá, và xác định tên địa điểm bằng Google Places, với đầu ra JSON cho script.