
































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

































Examination Details:
A. Executes individual tasks in parallel B. Maintains the SparkContext and coordinates job execution C. Stores cached RDD partitions D. Manages the Hadoop Distributed File System ANSWER: B EXPLANATION: The Driver runs the main() function, creates the SparkSession/SparkContext, converts user programs into DAGs, schedules tasks on executors, and collects results. It does NOT execute tasks itself. REFERENCE: Learning Spark, 2nd Ed., Ch. 2, p. 31.
Q3. How many SparkContexts can be active in a single JVM at one time? A. Unlimited B. One C. Two D. Depends on executor count
EXPLANATION: Spark enforces a single active SparkContext per JVM. Attempting to create a second throws "Only one SparkContext may be active in this JVM." SparkSession wraps SparkContext and follows the same rule. REFERENCE: Apache Spark Documentation — SparkContext.
Q4. Which Spark component is responsible for building the DAG (Directed Acyclic Graph) of stages? A. Executor B. Cluster Manager C. DAG Scheduler D. Task Scheduler ANSWER: C EXPLANATION: The DAG Scheduler converts the logical execution plan into a physical plan of stages, splitting at shuffle boundaries. The Task Scheduler then launches tasks within each stage.
A. Every transformation B. A shuffle boundary C. Every action D. Caching an RDD ANSWER: B EXPLANATION: Stages are separated by shuffle operations (e.g., groupByKey, reduceByKey, join). Narrow transformations within a stage are pipelined; wide transformations require a shuffle, creating a new stage. REFERENCE: Chambers & Zaharia, Ch. 15, p. 294.
Q7. Which of the following is a NARROW transformation? A. groupByKey() B. reduceByKey() C. map() D. join() (default)
EXPLANATION: map() is narrow because each input partition contributes to exactly one output partition — no data movement across the network. groupByKey, reduceByKey, and default joins are wide. REFERENCE: Learning Spark, 2nd Ed., Ch. 2, p. 33.
Q8. How many tasks does a single stage typically have? A. One per executor B. One per partition C. One per core D. One per node ANSWER: B EXPLANATION: Spark creates one task per partition per stage. If a stage operates on an RDD with 200 partitions, it launches 200 tasks (assuming enough executor slots).
A. Driver B. Executor C. Cluster Manager D. DAG Scheduler ANSWER: B EXPLANATION: Executors are JVM processes on worker nodes that run tasks, store cached data, and report status to the Driver. Each application gets its own set of executors. REFERENCE: Chambers & Zaharia, Ch. 2, p. 29.
Q11. What happens when you call an ACTION on a DataFrame in Spark? A. Nothing until you call .collect() B. The DAG is built and execution begins C. Only the schema is computed D. Data is written to disk
EXPLANATION: Actions trigger the lazy evaluation chain. The DAG Scheduler builds the physical plan, and tasks are launched. Transformations alone do NOT trigger execution. REFERENCE: Learning Spark, 2nd Ed., Ch. 3, p. 60.
Q12. Which BEST describes Spark's lazy evaluation? A. Transformations execute immediately B. Transformations build a lineage graph; execution waits for an action C. Only actions are lazy D. DataFrames cache automatically ANSWER: B EXPLANATION: Spark records transformations as a lineage (logical plan) and waits for an action to trigger optimization (Catalyst) and physical execution. This enables whole-stage code generation and predicate pushdown.
Q14. What is the default number of partitions when reading a file with spark.read.csv() on HDFS? A. 1 B. 2 C. Determined by HDFS block size (typically one per block) D. Always 200 ANSWER: C EXPLANATION: Spark creates one partition per HDFS block (default 128 MB). A 1 GB file yields ~8 partitions. spark.sql.files.maxPartitionBytes (default 128 MB) controls this. REFERENCE: Learning Spark, 2nd Ed., Ch. 4, p. 78.
Q15. Which configuration controls the default number of shuffle partitions? A. spark.default.parallelism
B. spark.sql.shuffle.partitions C. spark.executor.cores D. spark.partition.size ANSWER: B EXPLANATION: spark.sql.shuffle.partitions defaults to 200 for DataFrame/SQL shuffles. spark.default.parallelism applies to RDD shuffles and defaults to total executor cores. REFERENCE: Databricks Documentation — Spark Configuration.
Q16. What is a "task" in Spark terminology? A. A unit of work applied to one partition of data B. A complete Spark application C. A query plan node D. A cluster resource request ANSWER: A
Q18. In client mode vs cluster mode, where does the Driver run? A. Both run on the client machine B. Client mode: on client; Cluster mode: on a worker node in the cluster C. Both run in the cluster D. Client mode: on a worker; Cluster mode: on the client ANSWER: B EXPLANATION: In client mode, the Driver runs on the machine submitting the job (outside the cluster). In cluster mode, the Driver runs inside a cluster worker node. Cluster mode is preferred for production. REFERENCE: Learning Spark, 2nd Ed., Ch. 7, p. 120.
Q19. What is the purpose of the SparkSession?
A. Replaces SparkContext and provides a unified entry point for DataFrame, SQL, and Streaming APIs B. Only manages SQL queries C. Only manages RDDs D. Replaces the Cluster Manager ANSWER: A EXPLANATION: Since Spark 2.0, SparkSession is the unified entry point wrapping SparkContext, SQLContext, and HiveContext. Use SparkSession.builder().getOrCreate(). REFERENCE: Chambers & Zaharia, Ch. 3, p. 51.
Q20. Which of these is a WIDE transformation? A. filter() B. select() C. groupByKey() D. mapPartitions()
Q22. Which file format allows Spark to read only needed columns, dramatically improving performance? A. CSV B. JSON C. Parquet D. XML ANSWER: C EXPLANATION: Parquet is columnar with built-in schema. Spark can perform column pruning and predicate pushdown, reading only required columns — huge I/O savings. REFERENCE: Learning Spark, 2nd Ed., Ch. 4, p. 82.
Q23. What is the default parallelism for RDD operations (e.g., sc.parallelize)?
B. Number of executor cores available C. 1 D. Number of nodes × 10 ANSWER: B EXPLANATION: For RDDs, spark.default.parallelism defaults to the total number of cores across executors (or 2 in local mode). For sc.parallelize, partitions default to that value. REFERENCE: Apache Spark Documentation — Configuration.
Q24. Which statement about Broadcast Variables is TRUE? A. They are sent to executors once and cached read-only B. They are sent with every task C. They can be modified by executors D. They only work with RDDs ANSWER: A