AWS Training
Modules Listen Certification

← Senior Spark Technical Lead (Scala, Python) — Role Review

STL Cheat sheet — Spark, Scala, and Python for a lead, on one page

Every figure verified 2026-11-22 against the page cited in the matching lesson, on Apache Spark 4.3.0. "Observed" means it was run on 4.3.0 in local mode, not read from a doc. Re-verify before quoting; the ⚠️ items are flagged in the lessons.

Versions to know cold (lessons 1, 5, 6)

Spark 3.5.x Spark 4.3.0
Scala 2.12 / 2.13 2.13 only (2.12 dropped in 4.0.0)
Java 8 / 11 / 17 17 / 21 / 25 (8 and 11 dropped in 4.0.0)
Python 3.8+ 3.11+ (3.8 dropped in 4.0, 3.9 in 4.1, 3.10 in 4.3)
pandas / PyArrow — pandas >=2.2.0,<3.0.0, PyArrow >=18.0.0
ANSI mode off on (spark.sql.ansi.enabled, since 4.0)
Where Newest Spark Scala
Open source 4.3.0 (Oct 30, 2026) 4.3.0 2.13
EMR 8.x "AWS runtime for Apache Spark" emr-spark-8.2.0 (LTS) 4.1.3-amzn-0 2.13.17
EMR 7.x emr-7.14.0 3.5.8-amzn-0 2.12.18
AWS Glue 6.0 (default for new jobs) 4.1.1 2.13.17
AWS Glue 5.1 3.5.6 2.12.18

Scala for a reviewer (lesson 1)

See this Say this
var, mutable collection Scala docs: always val unless there's a reason. Mutable state plus closures is lesson 2's bug
.get on an Option Throws NoSuchElementException when empty. Use map / getOrElse / pattern match
null Option(javaCall) turns null into None. ⚠️ Some(null) is still a null (observed NPE)
match on a non-sealed type, no default Exhaustiveness is checked only for sealed, and only as a warning → scala.MatchError in production. Seal it; build with -Werror
return inside a lambda Non-local return is implemented by throwing; a catch Throwable swallows it (observed). Deprecated since Scala 3.2
ds.collect().map(...).groupBy(...) Same method names, but after collect() it is eager, local, single-JVM
Code that only compiled in spark-shell The shell pre-imports spark.implicits._ (observed); a job needs the import for $"col" and .toDS()

val evaluates once, def every call, lazy val once on first use. object = one instance, created lazily. Try catches only non-fatal exceptions. Either: Left is failure, Right is success, right-biased.

Datasets, encoders, closures (lesson 2)

Typed-API behaviour on 4.3.0 Observed
filter($"amount" > 498) on Parquet PushedFilters: [IsNotNull(amount), GreaterThan(amount,498.0)]
filter(o => o.amount > 498) PushedFilters: []; an object built per row. ⚠️ No DeserializeToObject node — that appears for map
Case-class field missing from data Fails at .as[T]: UNRESOLVED_COLUMN.WITH_SUGGESTION
Int field over a bigint column Fails at .as[T]: CANNOT_UP_CAST_DATATYPE
NULL in a primitive field Fails in a task: NOT_NULL_ASSERT_VIOLATION. Use Option[T]
groupByKey(...).mapGroups(...) No partial aggregation; shuffles all the data
Scala UDF in a filter Still PushedFilters: []

Task not serializable: the lambda read a field, so it captured this. Read the first line of the serialization stack — it names the class. Fixes, in order: copy the field to a local val; move the helper to an object; @transient lazy val for a non-serializable member. extends Serializable alone only moves the failure down a level (observed). Kryo does not cure it.

Accumulators: exactly-once only for updates inside actions; in transformations an update "may be applied more than once" (observed 0 → 100 → 200 over two count() calls). spark.serializer default: org.apache.spark.serializer.JavaSerializer.

Scala or Python (lesson 3)

Same engine, same plan. DataFrame and SQL code compiles to an identical physical plan in either language (observed: empty diff). The language matters only where your code runs on the rows.

Scala / Java Python
Typed Dataset[T] Yes No
UDF runs in The executor JVM A Python worker; Arrow transfer by default since 4.2 (spark.sql.execution.pythonUDF.arrow.enabled = true)
Vectorised UDF — pandas UDF; arrow_udf (4.1.0+)
Custom connector Data Source V2 (Java interfaces) Python Data Source API (4.0+), "lightweight"
Optimizer rules, parser SparkSessionExtensions (no stability guarantee) ⚠️ none found
transformWithState Yes; runs in Real-Time Mode since 4.3.0 Yes; not supported in Real-Time Mode
Ship dependencies Assembly jar, Spark and Hadoop provided --py-files (.py, .zip, .egg — no wheels); conda-pack / venv-pack via --archives; PEX via --files

Performance triage — the order (lesson 4)

  1. Waiting or working? Scheduler delay, executors actually granted.
  2. Which job → stage → tasks. The slow stage, not the code.
  3. Task distribution. Max against median: duration and shuffle read.
  4. Shuffle and spill. Shuffle spill (memory) / (disk) on the stage page.
  5. GC time.
  6. The plan. Scan (PartitionFilters, PushedFilters), join strategy, exchanges — from the SQL tab, because a pre-run explain under AQE shows isFinalPlan=false.
  7. The code. UDFs, collect, repeated actions. Last, not first.
Key 4.3.0 default
spark.sql.shuffle.partitions 200
spark.sql.adaptive.enabled true
spark.sql.adaptive.advisoryPartitionSizeInBytes 64 MB
spark.sql.adaptive.coalescePartitions.parallelismFirst true — ignores the target size
spark.sql.adaptive.skewJoin.enabled true
…skewJoin.skewedPartitionFactor / …skewedPartitionThresholdInBytes 5.0 / 256MB — both must be exceeded
spark.sql.autoBroadcastJoinThreshold 10 MB (-1 disables)
spark.sql.files.maxPartitionBytes 128 MB
spark.executor.memory / spark.driver.memory 1g / 1g
spark.executor.memoryOverheadFactor (min overhead) 0.10 (384m)
spark.memory.fraction / storageFraction 0.6 / 0.5
spark.driver.maxResultSize 1g
spark.dynamicAllocation.enabled / spark.speculation false / false
spark.eventLog.enabled false — turn it on, or there is no evidence afterwards

Review, test, deploy (lesson 5)

Review in blast-radius order: silently wrong → kills the job → slow.

Hazard Fact
Overwriting a partitioned path spark.sql.sources.partitionOverwriteMode default STATIC — deletes partitions you did not write (observed). Per-write option partitionOverwriteMode=dynamic takes precedence
Save modes Default errorifexists. They "do not utilize any locking and are not atomic"
Retry with append Duplicates (observed 3 → 6 rows)
Join key not unique Fan-out: 3 rows summing 22 became 5 rows summing 37 (observed)
NULL keys NOT IN with a NULL in the list returns no rows; <=> is the null-safe equal
withColumn in a loop Doc: "can generate big plans … even StackOverflowException". 50 calls → 50 Project nodes; one withColumns → 1 (observed)
collect / toPandas Only when the result is "expected to be small"
Window with no partitionBy Logs "Moving all data to a single partition"
UDF with side effects or randomness UDFs are deterministic by default and may run more or fewer times — asNondeterministic

The Spark 4 line (lesson 6)

Release Date Remember
4.0.0 May 23, 2025 ANSI on by default · Scala 2.13 / JDK 17 · VARIANT · Python Data Source API · Python UDTFs · SQL pipe syntax · transformWithState
4.1.0 Dec 16, 2025 Declarative Pipelines · SQL scripting GA · VARIANT GA · Real-Time Mode (Scala, stateless) · recursive CTEs · arrow_udf
4.2.0 Jul 14, 2026 Arrow on by default for Python UDFs / UDTFs · GEOMETRY / GEOGRAPHY · QUALIFY · Auto CDC (SCD 1) · Java 25
4.3.0 Oct 30, 2026 Stateful Real-Time Mode, no longer experimental · SCD Type 2 · JSON_TABLE · Python 3.10 dropped