home
diamond Go Premium
Data Engineering Path  ·  PySpark

PySpark RDD: Low-Level Transformations & Actions

Level Intermediate to Advanced
Estimated Time ~2.5 Hours
Curriculum 6 Lessons
Course Mission

"Master low-level PySpark RDD transformations, wide network shuffles, memory persistence levels, broadcast/accumulator variables, and RDD-to-DataFrame conversions."


What You'll Master

Transformations & Actions

Narrow operations (map, filter) vs wide shuffle operations (reduceByKey, join).

Partition Tuning

Repartitioning, coalescing, custom hash partitioners, & mapPartitions optimizations.

Memory & Caching

Cache vs Persist, memory storage levels (MEMORY_ONLY, MEMORY_AND_DISK_SER), & GC.

Shared Variables & Conversion

Broadcast lookup maps, global accumulator counters, & RDD-to-DataFrame conversions.


In Apache Spark, every RDD operation falls into one of two categories: Transformations, which take an existing Resilient Distributed Dataset (RDD) as input and produce a new RDD as output, and Actions, which trigger the physical execution of that work and return results to the Driver or save them to storage.

Due to Spark's Lazy Evaluation design, transformations do not execute immediately. Instead, they build a Directed Acyclic Graph (DAG) of execution. The actual calculations are only performed when an Action is called.

Transformations: Narrow vs. Wide Dependencies

Transformations are broadly classified into two categories depending on their performance and network communication patterns:

  1. Narrow Transformations (No Shuffle): Each partition of the parent RDD is used by at most one partition of the child RDD. Data is processed locally on the same worker node.
  2. Wide Transformations (Requires Shuffle): Multiple child partitions depend on data from a single parent partition. This forces data to be reshuffled across physical machines, which is highly disk and network I/O intensive.

Click on the links below to open the dedicated, detailed guides with PySpark code examples for each major transformation:

General Transformations (Narrow)

Pair RDD Transformations (Wide)

Tip

Always prefer Narrow Transformations over Wide Transformations where possible, and when performing aggregations, choose reduceByKey over groupByKey to minimize network overhead!

Actions: How They Work

When you call an action, Spark's DAG Scheduler evaluates the lineage graph, divides it into physical execution stages and tasks, and deploys them to the executor worker nodes.

Caution

Driver Memory Warning

Many actions (like collect()) pull computed data back from executor worker nodes into the single Driver machine's RAM. If the dataset size exceeds the Driver's heap limits, the application will experience an Out Of Memory (OOM) crash.

Always preview datasets using safe actions like take(n) or save large results directly to filesystems using saveAsTextFile().

Click on the links below to open the dedicated, detailed guides with PySpark code examples for each major action:

Retrieval Actions

Aggregation & Reduction Actions

  • RDD - Action Reduce Reduces elements using an associative and commutative binary function (e.g. sum, max).
  • RDD - Action Aggregate Advanced partition aggregation allowing the output type to differ from the input type (e.g. averages).

Storage & Utility Actions


Learning Path & Course Syllabus

Practical tracing exercises covering mapPartitions, key-based shuffles, and memory persistence levels.

Scenario questions covering RDD lineage, partition strategies, shuffle boundaries, and fault tolerance.


What's Included in This Module

Area Overview
Topics Covered PySpark RDD API, Narrow/Wide Transformations, Actions, Partitions, Caching, Broadcast & Accumulator Variables
Practical Code 29 Detailed Code Reference Files & Notebook Examples
Assessments 1 Hands-on RDD Execution Lab + 1 Senior System Design Interview Quiz
Find this content helpful? ☕ Buy me a coffee

Entity Details

Create New Item

celebration
Enjoying the free content?

Create a free account to track your progress and save your place.

Create Free Account
help

Submit Technical Query

Have a question or run into an issue? Describe it below, upload an optional screenshot, and our engineering team will answer it!

image Attach image (optional)

Submit Feedback

build Free Developer Utility Free Tool
gavel

Privacy & Legal Disclaimer

1. Client-Side Browser Processing

All utility tools on DeepEngineerHub (including Image to PDF, Text Formatters, JSON Converters, and Encryptors) execute 100% locally within your client browser using WebAssembly and JavaScript. No uploaded images, text, or documents are transmitted, collected, or stored on remote servers.

2. Limitation of Liability ("As-Is" Provision)

Tools and services are provided free of charge for convenience and educational purposes "as-is" without warranties of any kind. DeepEngineerHub shall not be held liable for any data loss, formatting inconsistencies, or indirect damages resulting from tool usage.

3. Open Source & Third-Party Software

Certain utilities utilize open-source client libraries (such as jsPDF, Mermaid.js, Pyodide) licensed under MIT, Apache, or BSD open licenses. All intellectual property remains with their respective copyright holders.