spark-version-upgrade
БесплатноБез исполняемых скриптовНе проверенUpgrade Apache Spark applications between major versions (2.x→3.x, 3.x→4.x). Covers build files, deprecated APIs, configuration changes, SQL/DataFrame…
от OpenHands★ 190 звёзд на GitHubОб этом скилле
Upgrade Apache Spark applications between major versions with a structured, phase-by-phase workflow.
When to Use
- Migrating from Spark 2.x → 3.x or Spark 3.x → 4.x
- Updating PySpark, Spark SQL, or Structured Streaming applications
- Resolving deprecation warnings before a Spark version bump
Workflow Overview
- Inventory & Impact Analysis — Scan the codebase and assess scope
- Build File Updates — Bump Spark/Scala/Java dependencies
- API Migration — Replace deprecated and removed APIs
- Configuration Migration — Update Spark config properties
- SQL & DataFrame Migration — Fix query-level breaking changes
- Test Validation — Compile, run tests, verify results
Phase 1: Inventory & Impact Analysis
Before changing any code, assess what needs to change. Read the official Apache Spark migration guide for the target version — it documents every API removal, config rename, and behavioral change per release: https://spark.apache.org/docs/latest/migration-guide.html
Checklist
- Read the migration guide section for the target Spark version
- Identify current Spark version (check
pom.xml,build.sbt,build.gradle, orrequirements.txt) - Identify target Spark version
- Search for deprecated APIs:
grep -rn 'import org.apache.spark' --include='*.scala' --include='*.java' --include='*.py' - List all Spark config properties:
grep -rn 'spark\.' --include='*.conf' --include='*.properties' --include='*.scala' --include='*.java' --include='*.py' | grep -v 'test' - On Windows PowerShell, use
Get-ChildItem -Recurse -Include *.scala,*.java,*.py | Select-String 'import org.apache.spark'and adjust the extensions/pattern for config searches. - Check for custom
SparkSessionorSparkContextextensions - Identify connector dependencies (Hive, Kafka, Cassandra, Delta, Iceberg)
- Document findings in
spark_upgrade_impact.md
Output
spark_upgrade_impact.md # Summary of affected files, APIs, and configs
Phase 2: Build File Updates
Update dependency versions and resolve compilation.
Maven (pom.xml)
<!-- Update Spark version property -->
<spark.version>3.5.1</spark.version> <!-- or 4.0.0 -->
<scala.version>2.13.12</scala.version> <!-- Spark 3.x: 2.12/2.13; Spark 4.x: 2.13 -->
<!-- Update artifact IDs if Scala cross-version changed -->
<artifactId>spark-core_2.13</artifactId>
<artifactId>spark-sql_2.13</artifactId>
SBT (build.sbt)
val sparkVersion = "3.5.1" // or "4.0.0"
scalaVersion := "2.13.12"
libraryDependencies += "org.apache.spark" %% "spark-core" % sparkVersion
libraryDependencies += "org.apache.spark" %% "spark-sql" % sparkVersion
Gradle (build.gradle)
ext {
sparkVersion = '3.5.1' // or '4.0.0'
}
dependencies {
implementation "org.apache.spark:spark-core_2.13:${sparkVersion}"
implementation "org.apache.spark:spark-sql_2.13:${sparkVersion}"
}
PySpark (requirements.txt / pyproject.toml)
pyspark==3.5.1 # or 4.0.0
Checklist
- Update Spark version in build file
- Update Scala version if crossing 2.12→2.13 boundary
- Update Java source/target level if required (Spark 4.x requires Java 17+)
- Update connector library versions to match new Spark version
- Resolve dependency conflicts (
mvn dependency:tree/sbt dependencyTree) - Confirm project compiles (errors at this stage are expected — they guide Phase 3)
Phase 3: API Migration
Replace removed and deprecated APIs. Work through compiler errors systematically.
Common Patterns
Consult the official Apache Spark migration guide for the complete list of changes for each version: https://spark.apache.org/docs/latest/migration-guide.html
SparkSession Creation (2.x → 3.x)
// BEFORE (Spark 1.x/2.x)
val sc = new SparkContext(conf)
val sqlContext = new SQLContext(sc)
// AFTER (Spark 2.x+/3.x)
val spark = SparkSession.builder()
.config(conf)
.enableHiveSupport() // if needed
.getOrCreate()
val sc = spark.sparkContext
RDD to DataFrame (2.x → 3.x)
// BEFORE
rdd.toDF() // implicit from SQLContext
// AFTER
import spark.implicits._
rdd.toDF() // implicit from SparkSession
Accumulator API (2.x → 3.x)
// BEFORE
val acc = sc.accumulator(0)
// AFTER
val acc = sc.longAccumulator("name")
Checklist
- Replace
SQLContext/HiveContextwithSparkSession - Replace deprecated
AccumulatorwithAccumulatorV2 - Update
DataFrame→Dataset[Row]where needed - Replace removed
RDD.mapPartitionsWithContextwithmapPartitions - Fix
SparkConfdeprecated setters - Update custom
UserDefinedFunctionregistration - Migrate
Experimental/DeveloperApiusages that were removed - Verify all compilation errors from Phase 2 are resolved
Phase 4: Configuration Migration
Spark renames and removes configuration prope
Установить spark-version-upgrade в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл spark-version-upgrade?
Upgrade Apache Spark applications between major versions (2.x→3.x, 3.x→4.x). Covers build files, deprecated APIs, configuration changes, SQL/DataFrame updates, and test validation.
Как установить скилл spark-version-upgrade?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл spark-version-upgrade запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic