WorksheetsSpark Arch & Component
Total questions: 30
Worksheet time: 15mins
RDDs in Spark are…
Which transformation creates a new RDD?
collect()
count()
map()
take()
Which of the following is an action on an RDD?
flatMap
filter
reduce
map
RDD lineage helps in:
Storing RDD data permanently
Recomputing lost partitions
Increasing cluster size
Scheduling cluster jobs
Which storage level provides the highest performance for RDD caching?
MEMORY_ONLY
DISK_ONLY
MEMORY_AND_DISK
OFF_HEAP
The DAG in Spark is created during:
Actions
Transformations
Both A and B
Neither A nor B
The DAG Scheduler in Spark converts the DAG into:
Blocks
Stages
Tasks
Executors
A stage is divided into tasks based on:
Number of executors
Number of partitions
Driver configuration
Cluster manager
The DAG created by Spark is:
Acyclic
Cyclic
Can be cyclic or acyclic
Always linear
Spark Driver is responsible for:
Running tasks on executors
Managing cluster resources
Converting logical plan into physical plan
Scheduling tasks
Which component actually executes tasks?
Driver
Executor
Cluster Manager
DAG Scheduler
Cluster Manager allocates:
Tasks
RDDs
Resources
Transformations
Which of the following is not a cluster manager used in Spark?
YARN
Mesos
Kubernetes
Jenkins
Which is true about Spark Executors?
They run on the driver node
They continue running for the entire application
They store metadata only
They schedule jobs
What is the output of the following code?
val rdd = sc.parallelize(Seq(1, 2, 3))
val result = rdd.map(_ * 2)
println(result.collect().mkString(","))
2, 4, 6
1, 2, 3
Compilation error
Runtime error
What type of operation is filter in the snippet below?
val rdd = sc.parallelize(Seq(5, 10, 15))
val result = rdd.filter(_ > 10)
Action
Transformation
Shuffle operation
Persistence operation
What will be printed?
val rdd = sc.parallelize(List("a","b","c"))
val mapped = rdd.map(x => x.toUpperCase)
println(mapped.first())
"a"
"A"
"C"
"A","B","C"
What does reduce return in this code?
val rdd = sc.parallelize(List(1,2,3,4))
val res = rdd.reduce(_ + _)
RDD[Int]
Int
Iterator[Int]
Array[Int]
What happens when the following code runs?
val rdd = sc.parallelize(Seq(1,2,3))
val cached = rdd.cache()
println(cached.count())
Data is cached after count()
Data is cached before count()
No caching happens
Throws exception
How many stages will this produce?
val rdd1 = sc.textFile("file1")
val rdd2 = rdd1.map(_.length)
val rdd3 = rdd2.reduce(_ + _)
1
Depends on file size
2
4
How many stages will this create?
val rdd = sc.parallelize(Seq(("a",1),("b",2),("a",3)))
val reduced = rdd.reduceByKey(_ + _)
println(reduced.collect().toList)
Depends on cluster size
1
2
3
Which action triggers DAG execution here?
val rdd = sc.parallelize(Seq(1,2,3)).map(_ * 3)
val result = rdd.filter(_ > 3)
result.count()
map
filter
count
parallelize
What does Spark build when running this?
val rdd1 = sc.parallelize(Seq(1,2))
val rdd2 = rdd1.map(_ + 1)
val result = rdd2.collect()
Physical execution plan directly
DAG then stages
Only one stage plan
No DAG needed
When is the DAG finalized in this flow?
val x = sc.textFile("data.txt").map(_.length)
x.reduce(_ + _)
During map
During reduce
After reduce executes
During textFile
Executor
Driver
Cluster Manager
Worker node
What happens when collect() is called?
val rdd = sc.parallelize(List(1,2)).map(_ * 10)
val result = rdd.collect()
Driver receives all results
Executors store results
Cluster manager merges tasks
DAG scheduler deletes RDD
What runs continuously throughout the application?
val rdd = sc.parallelize(Seq("x","y"))
rdd.count()
Driver
Executors
DAG Scheduler
Task Scheduler
What will be the schema of the following DataFrame?
val df = Seq((1, "Alice"), (2, "Bob"))
.toDF("id", "name")
df.printSchema()
id: String
name: String
id: Int
name: String
id: Long
name: String
Schema cannot be inferred
What does this code return?
val df = Seq(10, 20, 30).toDF("num")
val result = df.select(col("num") * 2)
A DataFrame with column num multiplied by 2
A DataFrame with no column name
A DataFrame with a column named "num"
A runtime error
What is the result of this code?
val df = Seq(("a", 1), ("b", 2), ("a", 3)).toDF("key", "value")
val result = df.groupBy("key").agg(sum("value"))
Fails due to missing alias
Groups by key and sums values
Returns same rows
Throws a runtime error
