QuestionQ4

VerifiedTroubleshooting and Tuning Apache Spark DataFrame API Applications.

The code block below contains a logical error that results in inefficiency. It is intended to efficiently perform a broadcast join of DataFrame storesDF and the much larger DataFrame employeesDF using key column storeId. Identify the logical error.

Code block:

storesDF.join(broadcast(employeesDF), "storeId")  
Explanation

A broadcast hint marks a DataFrame as small enough for a broadcast join, making that relation the broadcast/build side. Broadcasting the much larger employeesDF replicates it across executors and is inefficient; the smaller storesDF should be broadcast instead. Apache Spark documents that a BROADCAST hint makes the hinted relation the broadcast side, regardless of spark.sql.autoBroadcastJoinThreshold.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!