An e-commerce company runs a nightly AWS Glue ETL job that reads from Amazon S3, joins three large datasets, and writes results to Amazon Redshift. The job consistently takes 3–4 hours and the team wants to reduce runtime. A data engineer profiles the job and finds that one of the datasets — a 2 GB product dimension table — is being shuffled repeatedly across executors during every join. The other two datasets are 800 GB and 400 GB respectively. Which Spark optimization should the data engineer apply to reduce shuffle overhead for the dimension table joins?
- A. Use a broadcast join (broadcast hint) on the 2 GB product dimension table to eliminate shuffle✓ Correct
- B. Enable Glue job bookmarks so that previously processed partitions are skipped during the join
- C. Repartition all three datasets to the same number of partitions before joining to align shuffle boundaries
- D. Increase the number of Glue DPUs to add more executor memory and reduce spill to disk
Explanation
A broadcast join (also called a map-side join) sends a copy of the smaller dataset to every executor, completely eliminating the shuffle for that join. At 2 GB, the product dimension table may be large for default Spark broadcast thresholds (10 MB), but in Glue/EMR you can explicitly set spark.sql.autoBroadcastJoinThreshold or use a broadcast hint (broadcast()) to force it. This is the correct optimization for repeated shuffles of a known-small dimension table. Adding more DPUs increases parallelism and memory but does not eliminate the shuffle — it just makes it faster, which doesn't address the root cause. Repartitioning all datasets to aligned partition counts can reduce some skew but does not eliminate shuffles during joins; it may even add an extra shuffle step. Glue job bookmarks track processed data to avoid reprocessing but have no impact on join execution plans or shuffle behavior within a single job run.