Apache Spark Big Data (50 Qs)•Part 1: Basic & Foundational Concepts (Junior / Entry-Level)
What is the difference between Narrow Transformations and Wide Transformations?
junior LevelCode ExampleForms
In Simple Words:
- Narrow Transformation: Each input partition contributes to only one output partition. Requires zero network data exchange across nodes (e.g.
map(),filter(),flatMap()). - Wide Transformation: Data from multiple partitions must be grouped and exchanged across cluster nodes (Shuffle). Extremely expensive in network I/O and disk write (e.g.
groupBy(),reduceByKey(),join(),distinct()).
text
Narrow vs Wide Transformation:
Narrow (No Shuffle): [Part 1] -> [Part 1'] [Part 2] -> [Part 2']
Wide (Shuffle Required): [Part 1] ───┬───► [Part 1']
[Part 2] ───┴───► [Part 2']