Reference notes for the current Associate Developer for Apache Spark exam. Each section names the object, and what you check in a session you are allowed to delete.
Guide published October 8, 2026Python DataFrame APISeven sections
How to read these notes: Unmarked items sit on the public exam guide or the Spark docs it points at. Items tagged Extra are job context that outline does not require. New to the exam? Start with the overview. Practice in a Spark session you can remove.
Architecture and components
20 percent. The driver, lazy plans, shuffles, cache levels, and the modules.
Who does what
The driver holds the SparkSession, builds the plan, and schedules tasks. Executors run those tasks and store cached blocks. A cluster manager such as standalone, YARN, or Kubernetes assigns machines. The Spark UI displays the application. It does not run the tasks.
Lazy plans and actions
select, filter, withColumn, and groupBy build a plan. DataFrame.count(), show, collect, take, and a write trigger execution. groupBy("id").count() returns a DataFrame and stays lazy. An action can involve multiple jobs. Shuffle boundaries split jobs into stages. Each stage has one task per partition.
Shuffles, cache, and lineage
filter is narrow. A grouped aggregation, a non-broadcast join, distinct, and repartition are wide. spark.sql.shuffle.partitions defaults to 200 and sets an initial shuffle output count; AQE can coalesce partitions at runtime. DataFrame.cache() defaults to MEMORY_AND_DISK_DESER. RDD.cache() defaults to MEMORY_ONLY. A lost batch partition is recomputed from lineage. unpersist drops a cache you no longer reuse.
Modules
Spark Core executes. Spark SQL is the DataFrame and SQL planner. Structured Streaming extends that API to unbounded tables. MLlib is the machine-learning library. pyspark.pandas is the Pandas API on Spark. In Python you use a DataFrame, which is a Dataset of rows. The typed Dataset API is for Scala and Java. Extra Spark is a poor OLTP store. Single-row lookups are not the workload this engine is built for.
Spark SQL
20 percent. Save modes, file queries, tables, and views.
Save modes
The default mode fails if the destination already exists. overwrite replaces it. append adds files. ignore leaves the existing data and skips the new write. A partitioned replace of one day uses overwrite plus spark.sql.sources.partitionOverwriteMode set to dynamic. Static overwrite replaces the whole path the write touches.
Files and JDBC
df.write.mode("overwrite").partitionBy("country").parquet(path) both replaces and partitions. SQL can read parquet.`/path`, orc.`/path`, json.`/path`, csv.`/path`, text.`/path`, and delta.`/path`. JDBC uses format("jdbc") with a URL and a table. partitionBy is a file layout. It does not create folders inside a database table.
Tables and views
saveAsTable writes a catalog table. createOrReplaceTempView is session-scoped. createOrReplaceGlobalTempView is queried as global_temp.name and is visible to sessions in the same application. sortWithinPartitions orders rows inside current Spark partitions. Writer partitionBy makes directories; it does not guarantee row order in the output files, especially if a later shuffle occurs. orderBy requests a global sort.
Schemas
Pass schema on a CSV or JSON read when you do not want an inference scan. inferSchema can pick the wrong numeric type. A Parquet write stores the DataFrame schema. Extra header on CSV drops the first line from the data. It is not a schema.
DataFrame and Dataset API
30 percent. Columns, nulls, aggregates, dates, joins, and UDFs.
Columns and nulls
withColumn("state", col("division")) copies values. withColumnRenamed takes two strings, not a dict. drop removes a column. explode unnests an array and drops nulls. explode_outer keeps the outer row. na.drop() defaults to how="any". how="all" drops a row only when every value is null. subset limits the columns that are checked.
Aggregates and dates
count, countDistinct, approx_count_distinct, mean, and summary are the aggregate tools. approx_count_distinct uses HyperLogLog and is an estimate, not a more accurate distinct. from_unixtime turns epoch seconds into a string. to_timestamp parses a string. year, month, dayofmonth, and hour extract parts from a date or timestamp.
Joins and combining rows
inner drops unmatched rows. left keeps every left row. left_anti keeps left rows with no match. A duplicate key on the right multiplies the left. broadcast(small) asks for a broadcast hash join. DataFrame.union keeps duplicates and matches SQL UNION ALL. SQL UNION is distinct. unionByName aligns columns by name. dropDuplicates(["id"]) does not know which row is latest.
Actions, UDFs, and shared variables
printSchema prints a known schema without collecting rows. collect returns Row objects to the driver. show returns None. A built-in function beats a Python UDF. A pandas UDF runs on Arrow batches. For stateful grouped streams in PySpark, use GroupedData.applyInPandasWithState with an explicit state schema and timeout. A broadcast variable is read-only on executors. An accumulator is added on executors and read on the driver, and a transformation can add more than once if a task reruns.
Worked write: replace and partition
A frame must replace /data/orders and land in country directories:
append would keep the old files. Omitting mode fails when the path exists. overwrite without partitionBy replaces the path and does not split it by country. Read it back with spark.sql("SELECT * FROM parquet.`/data/orders`") and check that input_file_name() contains country=.
Troubleshooting and tuning
10 percent. Partition counts, skew, Adaptive Query Execution, and logs.
repartition and coalesce
repartition(n) shuffles and can raise or lower the count. coalesce(n) avoids a full shuffle and only reduces the count, so a large input partition can stay large. coalesce(1) makes one long task. Use it only when you truly want one file.
Skew and AQE
Skew is one key or partition with far more rows than the others. The stage view shows one long task. Adaptive Query Execution, on by default since Spark 3.2, can coalesce tiny shuffle partitions, split a skewed join partition, and switch a sort-merge join to broadcast from measured sizes. A salt splits a hot key when AQE is not enough. AQE does not rewrite source files or turn a Python UDF into a built-in.
Driver and executor memory
collect and toPandas fill the driver. One huge partition or a skewed shuffle fills an executor. Serialized cache levels reduce object churn and garbage collection. Open executor logs from the Spark UI stage view. spark-submit --verbose prints launch configuration. It is not the executor log.
What to read in the UI
Actions trigger jobs; the mapping is not always one to one. Stages show work separated by shuffle boundaries. The SQL tab shows the plan, including a broadcast exchange. Storage shows cached blocks. Extra On a managed cluster the log link may open the cluster manager. The diagnosis is still the stage, not a file you guess under /tmp on the master.
Structured Streaming
10 percent. Micro-batches, output modes, watermarks, and checkpoints.
The model
A streaming DataFrame is an unbounded table processed in micro-batches. New data updates the result instead of rereading a static archive. select and filter look like batch code. The query starts at the write, where you set the output mode and checkpointLocation. printSchema does not start it.
Output modes and windows
append emits finalized rows. complete rewrites the aggregation. update emits rows that changed. File save modes such as overwrite are a different API. window(col("event_time"), "10 minutes") builds a tumbling bucket. A watermark on event time lets append mode close a window. Late events older than the watermark can be dropped.
Dedup and exactly-once
dropDuplicates on a stream with no watermark remembers every key. For id-only deduplication with bounded state, use withWatermark on event time and dropDuplicatesWithinWatermark(["event_id"]) where available. With dropDuplicates, event time must be part of the deduplication key for watermark-based eviction. End-to-end exactly-once needs a replayable source, the checkpoint, and a sink that commits once or is idempotent. foreachBatch does not wrap an arbitrary database transaction.
Restart
The same checkpoint and a compatible query continue from the stored offsets. Deleting the checkpoint starts a new query and can reprocess the source. Extra Continuous processing is not the default engine. Study the micro-batch model unless a question names the other mode.
Spark Connect and deploy modes
5 percent. The remote client, plus client, cluster, and local mode.
Spark Connect
The client sends an unresolved plan to a Spark server. SparkSession.builder.remote("sc://host:15002") opens that session. Executors stay on the server. A huge collect still returns rows to the client and can exhaust it.
Classic deploy modes
Local mode runs the driver and the executors in one JVM. Client mode keeps the driver in the spark-submit process, so that process must stay up. Cluster mode runs the driver inside the cluster. Standard mode is not a Spark mode. A remote Connect session is not the same thing as cluster deploy mode.
Pandas API on Spark
5 percent. Distributed pandas-like code, and pandas UDFs.
The API
import pyspark.pandas as ps. The work stays distributed when you do not call to_pandas(). to_spark() hands you a PySpark DataFrame. to_pandas() collects to the driver. The older Koalas import is not the current package. import pandas is single-machine.
Pandas UDFs
pandas_udf runs Python on Arrow batches. A scalar pandas UDF takes a Series and returns a Series. A grouped map receives each group as a pandas DataFrame after a shuffle on the group key. A row-at-a-time Python UDF serializes one row at a time. Arrow does not remove that shuffle.
Seven checks on a disposable session
Say what you expect to see before you change the plan. Then stop the session if it was only for practice.
A write that must fail, then replace
Write Parquet to a new path, write the same path again with no mode, then write it with overwrite and partitionBy.
What to verify: the second write raises an error because data already exists. The third write leaves country= directories. append is not what produced those directories.
A union that kept duplicates
Union a two-row frame with itself and count.
What to verify: the count is 4. DataFrame.union did not deduplicate. distinct brings it back to 2. A SQL UNION of the same rows returns 2.
A null rule
Build a row with one null column and a row of all nulls. Call na.drop() and na.drop("all").
What to verify: the default drop removes the partial row. how="all" removes only the row that is entirely null.
A collect that belongs on the driver
Filter to a handful of rows, collect them, and also explain a plan that still has a collect of the unfiltered frame.
What to verify: the small collect returns Row objects. The unfiltered collect is the action you would remove. printSchema does not return those rows.
A stream that continues
Start a streaming count with a checkpoint directory, stop it, and start it again with the same directory.
What to verify: the query uses the stored offsets. A new empty checkpoint directory is a different query. The console sink is not the checkpoint.
A cache that materializes on an action
Call cache() on a DataFrame, check its storage level, then run count() and inspect the Storage tab. Call unpersist() after the final reuse.
What to verify: the configured level is MEMORY_AND_DISK_DESER. cache() alone is lazy; an action materializes blocks, and unpersist removes them.
A local sort that does not promise output order
Compare sortWithinPartitions("event_time") with orderBy("event_time") in explain plans. Then add a write with partitionBy("country") and inspect the final plan.
What to verify: the local sort operates within current partitions. orderBy requests a global sort. Directory partitioning is a file layout and can change the physical plan.
An evidence-first Spark sequence
Read a small file with a schema, filter it, and do not call an action yet. The plan exists and the job list is unchanged. Call count and watch one job appear. Cache the filtered frame, call count again, and look for a storage entry. Then unpersist and confirm the block is gone. That sequence separates a transformation, an action, and a cache without a cluster you have to keep.
Frequently asked questions
Which exam do these notes follow?
These notes follow Databricks Certified Associate Developer for Apache Spark and the exam guide published October 8, 2026. Code examples are Python. Items tagged Extra are deeper product facts for practice. Spark 3.0 is not this outline.
Does cache() on a DataFrame use MEMORY_ONLY?
No. DataFrame.cache() defaults to MEMORY_AND_DISK_DESER in current PySpark. RDD.cache() defaults to MEMORY_ONLY. Ask for another level with persist and a StorageLevel.
Does DataFrame.union remove duplicates?
No. DataFrame.union keeps duplicates and matches SQL UNION ALL. SQL UNION removes duplicates. Call distinct when the DataFrame result must drop them.
Where should a large collect run?
It should not. collect and toPandas send rows to the driver. Aggregate, limit, or write when the result is large. A driver out-of-memory error with healthy executors usually starts at that action.
Continue the Spark study path
Use the notes, then test recall with cards and a timed practice set.
Certicab provides general informational, educational, and convenience resources. Learning materials can contain errors or become outdated. Check the current exam guide and official documentation before relying on a technical recommendation. Practice only in environments you own or are authorized to use, and do not share credentials or confidential exam material. Study resources are independent and do not guarantee exam success or imply certification-provider endorsement. Databricks is a trademark of Databricks, Inc. Apache Spark is a trademark of the Apache Software Foundation. Certicab is not affiliated with, endorsed by, or sponsored by Databricks, Inc. or the Apache Software Foundation.