How do we broadcast a small lookup dimension table to all executors to eliminate a costly SortMergeJoin shuffle?
broadcast(smallDF) copies the small table to every executor node, transforming the join into a BroadcastHashJoin.
Massively accelerating joins between massive fact tables (billions of rows) and small dimension tables.
from pyspark.sql.functions import broadcast
optimized_join = large_fact.join(broadcast(small_dim), "country_code", "inner")Practice typing production-grade PySpark code for Small-Table Broadcast Joins with broadcast().