Apache Spark Big Data (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Adaptive Query Execution (AQE): Dynamic coalescing of shuffle partitions, dynamic switching to broadcast joins, and runtime skew join mitigation.
senior Levelapache-sparkAdvanced Internals
In Simple Words: Before AQE (Spark 3.0+), Spark had to guess execution plans using static estimates:
- Dynamic Coalescing of Shuffle Partitions: Automatically merges small post-shuffle partitions together, solving the
spark.sql.shuffle.partitions = 200guessing game. - Dynamic Join Strategy Conversion: If a table was estimated at 50MB but filters reduce it to 5MB at runtime, Spark dynamically switches from an expensive SortMergeJoin to a lightning-fast BroadcastHashJoin.
- Dynamic Skew Join Handling: Automatically detects skewed partitions exceeding size thresholds and splits them into smaller sub-partitions joined in parallel, eliminating slow straggler tasks.