DATABRICKS-CERTIFIED-ASSOCIATE-DEVELOPER-FOR-APACHE-SPARK · Question #143
A Spark application has a 128 GB DataFrame A and a 1 GB DataFrame B. If a broadcast join were to be performed on these two DataFrames, which of the following describes which DataFrame should be…
The correct answer is D. DataFrame B should be broadcasted because it is smaller and will eliminate the need for the. In a broadcast join, one DataFrame is copied in its entirety to every executor in the cluster so that join lookups can happen locally without shuffling the larger DataFrame across the network. You should always broadcast the smaller DataFrame. Here, DataFrame B at 1 GB is small…
Question
A Spark application has a 128 GB DataFrame A and a 1 GB DataFrame B. If a broadcast join were to be performed on these two DataFrames, which of the following describes which DataFrame should be broadcasted and why?
Options
- AEither DataFrame can be broadcasted. Their results will be identical in result and efficiency.
- BDataFrame B should be broadcasted because it is smaller and will eliminate the need for the
- CDataFrame A should be broadcasted because it is larger and will eliminate the need for the
- DDataFrame B should be broadcasted because it is smaller and will eliminate the need for the
- EDataFrame A should be broadcasted because it is smaller and will eliminate the need for the
How the community answered
(41 responses)- A2% (1)
- D93% (38)
- E5% (2)
Explanation
In a broadcast join, one DataFrame is copied in its entirety to every executor in the cluster so that join lookups can happen locally without shuffling the larger DataFrame across the network. You should always broadcast the smaller DataFrame. Here, DataFrame B at 1 GB is small enough to be efficiently copied to all executors. This eliminates the expensive shuffle that would otherwise be required to co-locate matching rows from both DataFrames. Broadcasting DataFrame A (128 GB) would be impractical - sending 128 GB to every executor would exhaust executor memory and negate any performance benefit.
Topics
Community Discussion
No community discussion yet for this question.