0
0
Apache Sparkdata~10 mins

Transformations vs actions in Apache Spark - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new RDD by doubling each number.

Apache Spark
rdd2 = rdd.[1](lambda x: x * 2)
Drag options to blanks, or click blank then click option'
Acount
Breduce
Ccollect
Dmap
Attempts:
3 left
💡 Hint
Common Mistakes
Using actions like collect or count instead of transformations.
2fill in blank
medium

Complete the code to get the total count of elements in the RDD.

Apache Spark
total = rdd.[1]()
Drag options to blanks, or click blank then click option'
Acount
Bmap
Cfilter
DflatMap
Attempts:
3 left
💡 Hint
Common Mistakes
Using transformations like map or filter instead of an action.
3fill in blank
hard

Fix the error in the code to collect all elements as a list.

Apache Spark
elements = rdd.[1]()
Drag options to blanks, or click blank then click option'
Acollect
Breduce
Cmap
Dfilter
Attempts:
3 left
💡 Hint
Common Mistakes
Using transformations like map or filter which return RDDs, not lists.
4fill in blank
hard

Fill both blanks to create a filtered RDD and count its elements.

Apache Spark
filtered = rdd.[1](lambda x: x > 10)
count = filtered.[2]()
Drag options to blanks, or click blank then click option'
Afilter
Bcount
Cmap
Dcollect
Attempts:
3 left
💡 Hint
Common Mistakes
Using map instead of filter, or collect instead of count.
5fill in blank
hard

Fill all three blanks to create a mapped RDD, filter it, and collect the results.

Apache Spark
mapped = rdd.[1](lambda x: x * 3)
filtered = mapped.[2](lambda x: x < 20)
result = filtered.[3]()
Drag options to blanks, or click blank then click option'
Amap
Bfilter
Ccollect
Dcount
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up transformations and actions, or using count instead of collect.