Github user zsxwing commented on a diff in the pull request:

    https://github.com/apache/spark/pull/7774#discussion_r36057425
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashOuterJoin.scala
 ---
    @@ -57,13 +57,26 @@ case class BroadcastHashOuterJoin(
       override def requiredChildDistribution: Seq[Distribution] =
         UnspecifiedDistribution :: UnspecifiedDistribution :: Nil
     
    +  /**
    +   * Use lazy so that we won't do broadcast when calling explain but still 
cache the broadcast value
    +   * for the same query.
    +   */
       @transient
    -  private val broadcastFuture = future {
    -    // Note that we use .execute().collect() because we don't want to 
convert data to Scala types
    -    val input: Array[InternalRow] = 
buildPlan.execute().map(_.copy()).collect()
    -    val hashed = HashedRelation(input.iterator, buildKeyGenerator, 
input.size)
    -    sparkContext.broadcast(hashed)
    -  }(BroadcastHashOuterJoin.broadcastHashOuterJoinExecutionContext)
    +  private lazy val broadcastFuture = {
    --- End diff --
    
    > so does this do broadcast sequentially now though? Is that OK @rxin?
    
    Yes if there are multiple `BroadCasthashJoin`s in the same query. However, 
I feel it's not intuitive that launching some jobs when the user only types 
`explain`.
    
    To fix it, maybe we should add something like `doPrepare()` in SparkPlan 
and call all `doPrepare()`s of the SparkPlan tree before calling any 
`doExecute`.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to