Subdomain 1.2: Identify the role of core components of Apache Spark™'s Architecture, including cluster, driver node, worker nodes/executors, CPU cores, and memory.
1.A PySpark application calls three actions in sequence: `df1.count()`, `df2.write.parquet(path)`, and `df3.collect()`. On the Spark UI's Jobs tab, how many jobs and what triggers each one?
- A.Three separate jobs, because Spark launches one job per action, and each job is then broken into stages and tasks that run on the executors.
- B.One job, because Spark batches every action in a script into a single job that only starts once the driver reaches the end of the file.
- C.Three jobs, but only the two write actions actually launch tasks on executors; `count()` is resolved entirely inside the driver's JVM.
- D.Two jobs, because `collect()` and `count()` are lazy aggregation calls that Spark merges into the job triggered by the `write.parquet` action.
- E.One job per unique DataFrame lineage, so `df1`, `df2`, and `df3` each contribute to the same job since they share the same SparkSession.
Show answer & explanation
Correct answer: A — Three separate jobs, because Spark launches one job per action, and each job is then broken into stages and tasks that run on the executors.
- A. Correct. Each action triggers Spark's lazy-evaluated transformations to actually execute, and the driver submits a distinct job per action, which is then split into stages and tasks.
- B. Incorrect. Spark does not defer job submission to the end of the script; each action independently triggers its own job as soon as it is called.
- C. Incorrect. `count()` still requires reading and aggregating the underlying partitions across executors; it is not resolved purely inside the driver without executor work.
- D. Incorrect. Each action produces its own job in the Spark UI; `collect()` and `count()` are not merged into a job triggered by an unrelated `write.parquet` call on a different DataFrame.
- E. Incorrect. Job counting is tied to actions, not to shared lineage or a shared SparkSession; three actions on three DataFrames still produce three jobs even under one session.