Home / Databricks Certified Associate Developer for Apache Spark (Spark 3.5, Python) / Mock exam
Databricks Certified Associate Developer for Apache Spark (Spark 3.5, Python) Exam-style mock test

Databricks Certified Associate Developer for Apache Spark Practice Exams|Practice test

Full explanations Exam format Pass line 70%
33 USD One-time · lifetime access
Enroll →

Sample questions

Example1 · Apache Spark Architecture and Execution Model
At a B2B SaaS analytics firm, a PySpark job that aggregates tenant usage logs is submitted to a Spark cluster. A new engineer asks which component is responsible for converting the application's transformations into a DAG, scheduling tasks, and coordinating the overall execution. Which component performs this coordinating role?
✓The driver program, which hosts the SparkSession, builds the DAG, and schedules tasks across executors
Correct. The driver runs the main program, holds the SparkSession, builds the logical and physical plans into a DAG, and schedules tasks onto executors.
・The cluster manager, which allocates physical resources but does not plan task execution
Incorrect. The cluster manager (YARN, Kubernetes, standalone) grants resources but does not translate transformations into a DAG or schedule individual tasks.
・The executors, which run the assigned tasks and hold data partitions in memory
Incorrect. Executors execute tasks and cache partitions, but they do not plan or schedule the overall job; they receive work from the driver.
・The worker node, a machine that hosts executor processes for the job
Incorrect. A worker node is a host machine for executor processes and is infrastructure, not the logical coordinator of execution.
Explanation
The driver is the central coordinator: it owns the SparkSession, constructs the DAG from the user's transformations and actions, and schedules tasks to executors. The cluster manager only handles resource allocation.
Example2 · DataFrame API: Selecting, Filtering, and Transforming
At a B2B SaaS company, an analyst has a DataFrame named accounts with columns account_id, mrr, and seats. They need a new DataFrame containing only the account_id column and the mrr column, with mrr renamed to monthly_revenue. Which PySpark expression produces this result?
✓accounts.select("account_id", col("mrr").alias("monthly_revenue"))
Correct. select accepts a mix of column names and column expressions, and col("mrr").alias("monthly_revenue") renames the projected column, yielding exactly account_id and monthly_revenue.
・accounts.filter("account_id").filter(col("mrr").alias("monthly_revenue"))
Incorrect. filter is used to restrict rows with a boolean condition, not to project or rename columns, so this does not select the requested columns.
・accounts.select("account_id").withColumn("mrr", "monthly_revenue")
Incorrect. This drops mrr entirely with the first select, and withColumn with a string literal would not rename an existing column as intended.
・accounts.select("account_id", "mrr").rename("mrr")
Incorrect. The DataFrame API has no rename method, so this expression raises an AttributeError.
Explanation
Projecting a subset of columns and renaming one is done with select combined with col(...).alias(...).
Example3 · Aggregations, Joins, and Grouping
A data engineer at a B2B SaaS company has a DataFrame `events` with columns `account_id` and `revenue`. They need the total revenue per account, with the output column named `total_revenue`. Which snippet produces this result?
✓events.groupBy("account_id").agg(sum("revenue").alias("total_revenue"))
Correct. groupBy on account_id followed by agg(sum(...).alias(...)) yields one row per account with the renamed sum column.
・events.agg("account_id", sum("revenue").alias("total_revenue"))
Incorrect. agg does not accept a column name as a grouping argument; grouping must be done with groupBy first.
・events.select("account_id").sum("revenue").withColumnRenamed("sum(revenue)", "total_revenue")
Incorrect. A plain select does not create groups, and DataFrame has no direct sum method after select in this form.
・events.groupBy("account_id").sum("revenue").alias("total_revenue")
Incorrect. groupBy(...).sum("revenue") returns a DataFrame, and alias on a DataFrame does not rename the sum column.
Explanation
Per-group aggregation requires groupBy followed by agg, and alias renames the resulting aggregate column.
Example4 · Spark SQL, Functions, and UDFs
A data engineer at a healthcare services firm has a DataFrame named claims_df holding insurance claim records. They want to run ad-hoc SQL against it within the current SparkSession without persisting it to the metastore. Which approach makes claims_df queryable by SQL for the rest of this session?
✓Call claims_df.createOrReplaceTempView("claims") and then run spark.sql("SELECT * FROM claims")
Correct. createOrReplaceTempView registers a session-scoped temporary view that spark.sql can then reference by name.
・Call claims_df.write.saveAsTable("claims") so the data is registered permanently in the catalog
Incorrect. saveAsTable writes a managed/persistent table to the metastore, which is not an ephemeral session-only view.
・Call spark.catalog.cacheTable("claims_df") to expose the DataFrame directly to the SQL parser
Incorrect. cacheTable operates on an already-registered table or view name, not on a DataFrame variable, and does not create a queryable name.
・Call claims_df.toTable("claims") which publishes the rows as a session-scoped SQL alias
Incorrect. toTable writes to a persistent table in the catalog rather than creating a temporary session view.
Explanation
Temporary views created with createOrReplaceTempView expose a DataFrame to Spark SQL for the lifetime of the SparkSession without touching the metastore.
Example5 · I/O, Partitioning, Caching, and Performance Tuning
A healthcare services firm stores billions of claim records that analysts query by selecting only a handful of columns (patient_id, procedure_code, amount). The data engineering team wants to minimize the bytes Spark reads from storage for these column-selective queries. Which file format should they adopt for this dataset?
✓Apache Parquet, because its columnar layout lets Spark read only the referenced columns and skip the rest
Correct. Parquet is columnar, so Spark performs column pruning and reads only the requested columns, drastically reducing I/O for column-selective queries.
・Line-delimited JSON, since each record is self-describing and Spark can infer the schema at read time without a separate definition
Incorrect. JSON is row-oriented and text-based, so Spark must read and parse entire records even when only a few fields are needed.
・Plain CSV, because it is widely compatible and Spark can split the text files across many tasks for parallelism
Incorrect. CSV is row-oriented text; Spark reads full rows and cannot prune unused columns on disk, increasing I/O.
・Gzip-compressed CSV, which shrinks storage footprint and is directly readable by Spark's text source
Incorrect. Gzip-compressed CSV is both row-oriented and non-splittable, worsening both column pruning and parallelism.
Explanation
Columnar formats like Parquet enable column pruning so Spark reads only the needed columns, minimizing I/O for selective analytical queries.
Example6 · Apache Spark Architecture and Execution Model
A healthcare services firm runs a nightly PySpark job that aggregates patient admission records. The platform team wants to understand which component holds the SparkContext, builds the logical and physical plans, and schedules tasks across the cluster. Which component is responsible for this?
・The cluster manager, which allocates the machines and decides exactly which transformations each worker will run on its local data
Incorrect. The cluster manager only allocates resources; it does not build plans or schedule individual tasks against partitions.
✓The driver, which hosts the SparkContext, converts the user code into a DAG of stages and tasks, and schedules them
Correct. The driver hosts the SparkContext, translates user code into a DAG of stages and tasks, and schedules those tasks onto executors.
・An executor, which maintains the SparkContext and dispatches scheduled tasks back to the driver for aggregation
Incorrect. Executors run tasks and return results; they do not host the SparkContext or perform scheduling.
・The worker node, which compiles the plan
Incorrect. A worker node hosts executor processes but does not itself compile the query plan.
Explanation
The driver is the process that runs the main program, holds the SparkContext, builds the execution plan (DAG), and coordinates task scheduling across executors.
Example7 · Apache Spark Architecture and Execution Model
At the retailer UrbanThread, a data engineer submits a PySpark job that aggregates daily sales. She wants to understand which component is responsible for coordinating the overall execution, maintaining information about the application, and scheduling tasks across the cluster. Which component plays this role?
✓The driver, which hosts the SparkSession, builds the logical and physical plans, and schedules tasks onto executors
Correct. The driver runs the main program, holds the SparkSession, analyzes and plans the work, and schedules tasks on executors.
・The cluster manager, which allocates physical hardware and owns the DataFrame transformations in the job
Incorrect. The cluster manager allocates resources but does not own transformations or coordinate task scheduling within the application.
・The executor processes, which coordinate the job and distribute tasks
Incorrect. Executors run tasks and hold data, but they do not coordinate the job or distribute tasks themselves.
・The worker node daemon that stores all shuffle data
Incorrect. A worker node daemon launches executors; it is not the coordinating component and does not store all shuffle data.
Explanation
The driver is the central coordinator of a Spark application: it maintains application state, plans the work, and schedules tasks onto executors.
Example8 · Apache Spark Architecture and Execution Model
UrbanThread's analytics cluster has four executors, each with multiple cores. During a sales-aggregation job, an engineer asks what each executor is actually doing while the stage runs. Which statement best describes the responsibility of an executor?
・It parses the user's Python code and rewrites the DataFrame API calls into an optimized logical plan for the whole cluster
Incorrect. Parsing code and building the optimized logical plan is the driver's job, not the executor's.
✓It runs the individual tasks assigned to it and caches data partitions in memory or on disk, reporting results back to the driver
Correct. Executors execute the tasks the driver assigns, store cached partitions, and return results and status to the driver.
・It decides how many partitions the final shuffle should produce for the job
Incorrect. Shuffle partition counts are determined by configuration and the planner on the driver, not by an executor.
・It allocates CPU and memory to the entire Spark application
Incorrect. Resource allocation to the application is handled by the cluster manager, not by an executor.
Explanation
Executors are the workhorses: they run tasks, hold cached data, and communicate results back to the driver that assigned the work.
Example9 · Apache Spark Architecture and Execution Model
An UrbanThread engineer writes: df = spark.read.parquet('/sales'); filtered = df.filter(df.region == 'EU'); grouped = filtered.groupBy('store').count(). After running these three lines, no Spark job has started. Why has execution not begun yet?
・Because reading Parquet always defers until a checkpoint is written to disk explicitly
Incorrect. Parquet reads are not deferred by checkpointing; the deferral here is due to lazy transformations.
✓Because filter and groupBy are transformations that are lazily evaluated and build a plan without triggering computation
Correct. filter and groupBy are transformations; Spark builds a lineage lazily and only executes when an action is invoked.
・Because the DataFrame has not yet been cached in executor memory
Incorrect. Caching is optional and does not control whether a job starts; actions do.
・Because groupBy requires a wide dependency that Spark refuses to run
Incorrect. Wide dependencies are run normally; Spark does not refuse to execute groupBy.
Explanation
Transformations are lazy and only construct a plan. A job runs only when an action such as count() or show() is called to materialize results.
Example10 · Apache Spark Architecture and Execution Model
A data engineer at a retail bank submits a nightly PySpark job that aggregates card transactions. During the run, one component schedules tasks, tracks job progress, and collects the final aggregated results back to the submitting process. Which Spark component performs these responsibilities?
✓The driver, which converts the application into jobs, schedules tasks across the cluster, and gathers results
Correct. The driver hosts the SparkContext, turns the application into jobs and stages, schedules tasks, and collects results returned to the program.
・The cluster manager, which only allocates compute resources
Incorrect. The cluster manager (YARN, Standalone, or Kubernetes) negotiates and allocates resources but does not schedule individual Spark tasks or collect results.
・An executor, which runs the assigned tasks and stores data partitions
Incorrect. Executors run the tasks the driver assigns and cache partitions, but they do not orchestrate scheduling or gather final results centrally.
・The worker node daemon that launches JVM processes
Incorrect. The worker daemon launches executor processes on a node; it does not coordinate task scheduling or result collection.
Explanation
The driver is the central coordinator: it builds the execution plan, schedules tasks, and receives results. Executors perform work, and the cluster manager only provides resources.
Example11 · Apache Spark Architecture and Execution Model
A fraud-analytics team at an insurance firm runs a Spark job on executors each configured with 4 cores. A colleague asks how many tasks a single one of these executors can run at the same instant. What is the correct answer?
・As many tasks as there are partitions assigned to that executor, regardless of its core count
Incorrect. Partitions can far exceed slots; they queue and are processed as slots free up, not all at once.
✓Up to 4 tasks concurrently, because each core provides one task slot
Correct. An executor runs one concurrent task per core, so 4 cores allow 4 tasks to execute in parallel at any moment.
・Exactly 1 task, because an executor processes partitions strictly one after another
Incorrect. A multi-core executor runs multiple tasks concurrently, not strictly one at a time.
・8 tasks, since each core runs two tasks in parallel by default
Incorrect. Each core provides a single task slot by default, not two.
Explanation
Task-level parallelism within an executor is bounded by its core count: one slot per core. Partitions are processed through these slots as they become available.
Example12 · Apache Spark Architecture and Execution Model
At Meridian Industrial Supply, a data engineer runs a PySpark job that aggregates daily shipment records across the warehouse cluster. During the run, which component is responsible for converting the engineer's DataFrame operations into a logical and physical plan and scheduling the resulting tasks?
・Each executor independently parses the submitted Python code and builds its own physical plan before running tasks on its assigned partitions.
Incorrect. Executors do not parse the submitted code or build plans; they only run the tasks sent to them by the driver.
✓The driver program, which maintains the SparkSession and coordinates the scheduling of tasks.
Correct. The driver hosts the SparkSession, builds the logical and physical plans, and schedules tasks across executors.
・The cluster manager, which allocates compute resources and then compiles the DataFrame operations into executable task code.
Incorrect. The cluster manager allocates resources but does not compile DataFrame operations into task code; that is the driver's job.
・The worker nodes, because they hold the partition data and therefore decide the execution order of all stages.
Incorrect. Worker nodes host executors and data but do not decide stage execution order; the driver's scheduler does.
Explanation
The driver program runs the SparkSession, translates user operations into logical then physical plans via Catalyst, and coordinates task scheduling, while executors simply run the tasks they receive.
Example13 · Apache Spark Architecture and Execution Model
Meridian Industrial Supply loads a 48-partition DataFrame of purchase orders onto a cluster whose executors expose 12 total task slots. How does Spark process the work during a single stage?
・It merges the 48 partitions into 12 larger partitions first and then launches exactly one task for each of the 12 executor slots.
Incorrect. Spark does not automatically coalesce partitions to match slot count; each of the 48 partitions becomes its own task.
✓It processes partitions in waves, running up to 12 tasks concurrently and launching more as slots free up until all 48 are done.
Correct. One task runs per partition, and with only 12 slots the 48 tasks execute in concurrency-limited waves.
・It launches 48 tasks all at once, and the executors queue the extra tasks internally so every partition starts immediately on arrival.
Incorrect. Only as many tasks as there are free slots run concurrently; the scheduler does not start all 48 at once.
・It assigns four partitions to each task so that 12 tasks each sequentially iterate over their group of partitions within the stage.
Incorrect. A task processes exactly one partition, not a group of four; 48 partitions yield 48 tasks.
Explanation
Spark creates one task per partition within a stage, and the number running concurrently is capped by available executor slots, so 48 tasks run in waves of up to 12.
Example14 · Apache Spark Architecture and Execution Model
A telecom operator runs a nightly PySpark job that aggregates call-detail records. The data engineer wants to know which component is responsible for creating the SparkSession, planning the job, and scheduling tasks across the cluster. Which component performs this role?
・The cluster manager, which allocates physical resources and decides how the DAG of stages and tasks is scheduled onto the available worker nodes
Incorrect. The cluster manager only grants resources (CPU, memory) and does not plan the job or schedule its tasks; task scheduling is driven by the driver.
・The executor, which hosts the SparkSession object and breaks the query into stages before sending them to the driver
Incorrect. Executors run tasks and hold data partitions; they do not host the SparkSession or plan the query.
✓The driver process
Correct. The driver process hosts the SparkSession, builds the logical and physical plans, and schedules tasks onto executors.
・The worker node daemon that launches executors and reports their heartbeat status back to the resource scheduler
Incorrect. The worker daemon launches executor JVMs but does not create the SparkSession or plan the application's jobs.
Explanation
The driver is the central coordinator: it runs the SparkSession, converts transformations into a DAG, and schedules the resulting tasks on executors.
Example15 · Apache Spark Architecture and Execution Model
While tuning a telecom churn-analysis job, an engineer notices that increasing the number of executor cores lets more work run at once. On a single executor in Spark 3.5, what primarily determines how many tasks it can run concurrently?
・The total number of partitions in the input DataFrame divided evenly across every executor registered with the application at submit time
Incorrect. Partition count affects how many tasks exist in total, but concurrency on one executor is bounded by its cores, not by a static division of partitions.
✓The number of cores allocated to that executor
Correct. Each core provides one task slot, so an executor runs as many tasks concurrently as it has cores.
・The amount of driver memory configured, because the driver dispatches each task slot individually to that executor over the network
Incorrect. Driver memory does not set executor task concurrency; the driver dispatches tasks but the slots come from executor cores.
・The number of stages present in the DAG, since every stage reserves one dedicated thread per executor regardless of core count
Incorrect. Stages run sequentially per path in the DAG and do not each reserve a thread; cores define the concurrent task slots.
Explanation
An executor's concurrency equals its core count: one task per core slot at a time.
▶ Try 10 free questions (graded)
Measure your readiness with a full mock exam
All questions · full explanations · lifetime access
Enroll(33 USD)