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

    https://github.com/apache/spark/pull/7904#discussion_r36486388
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/BroadcastHashOuterJoin.scala
 ---
    @@ -1,122 +1,122 @@
    -/*
    - * Licensed to the Apache Software Foundation (ASF) under one or more
    - * contributor license agreements.  See the NOTICE file distributed with
    - * this work for additional information regarding copyright ownership.
    - * The ASF licenses this file to You under the Apache License, Version 2.0
    - * (the "License"); you may not use this file except in compliance with
    - * the License.  You may obtain a copy of the License at
    - *
    - *    http://www.apache.org/licenses/LICENSE-2.0
    - *
    - * Unless required by applicable law or agreed to in writing, software
    - * distributed under the License is distributed on an "AS IS" BASIS,
    - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    - * See the License for the specific language governing permissions and
    - * limitations under the License.
    - */
    -
    -package org.apache.spark.sql.execution.joins
    -
    -import scala.concurrent._
    -import scala.concurrent.duration._
    -
    -import org.apache.spark.annotation.DeveloperApi
    -import org.apache.spark.rdd.RDD
    -import org.apache.spark.sql.catalyst.InternalRow
    -import org.apache.spark.sql.catalyst.expressions._
    -import org.apache.spark.sql.catalyst.plans.physical.{Distribution, 
Partitioning, UnspecifiedDistribution}
    -import org.apache.spark.sql.catalyst.plans.{JoinType, LeftOuter, 
RightOuter}
    -import org.apache.spark.sql.execution.{BinaryNode, SQLExecution, SparkPlan}
    -import org.apache.spark.{InternalAccumulator, TaskContext}
    -
    -/**
    - * :: DeveloperApi ::
    - * Performs a outer hash join for two child relations.  When the output 
RDD of this operator is
    - * being constructed, a Spark job is asynchronously started to calculate 
the values for the
    - * broadcasted relation.  This data is then placed in a Spark broadcast 
variable.  The streamed
    - * relation is not shuffled.
    - */
    -@DeveloperApi
    -case class BroadcastHashOuterJoin(
    -    leftKeys: Seq[Expression],
    -    rightKeys: Seq[Expression],
    -    joinType: JoinType,
    -    condition: Option[Expression],
    -    left: SparkPlan,
    -    right: SparkPlan) extends BinaryNode with HashOuterJoin {
    -
    -  val timeout = {
    -    val timeoutValue = sqlContext.conf.broadcastTimeout
    -    if (timeoutValue < 0) {
    -      Duration.Inf
    -    } else {
    -      timeoutValue.seconds
    -    }
    -  }
    -
    -  override def requiredChildDistribution: Seq[Distribution] =
    -    UnspecifiedDistribution :: UnspecifiedDistribution :: Nil
    -
    -  override def outputPartitioning: Partitioning = 
streamedPlan.outputPartitioning
    -
    -  // Use lazy so that we won't do broadcast when calling explain but still 
cache the broadcast value
    -  // for the same query.
    -  @transient
    -  private lazy val broadcastFuture = {
    -    // broadcastFuture is used in "doExecute". Therefore we can get the 
execution id correctly here.
    -    val executionId = 
sparkContext.getLocalProperty(SQLExecution.EXECUTION_ID_KEY)
    -    future {
    -      // This will run in another thread. Set the execution id so that we 
can connect these jobs
    -      // with the correct execution.
    -      SQLExecution.withExecutionId(sparkContext, executionId) {
    -        // 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)
    -      }
    -    }(BroadcastHashJoin.broadcastHashJoinExecutionContext)
    -  }
    -
    -  protected override def doPrepare(): Unit = {
    -    broadcastFuture
    -  }
    -
    -  override def doExecute(): RDD[InternalRow] = {
    -    val broadcastRelation = Await.result(broadcastFuture, timeout)
    -
    -    streamedPlan.execute().mapPartitions { streamedIter =>
    -      val joinedRow = new JoinedRow()
    -      val hashTable = broadcastRelation.value
    -      val keyGenerator = streamedKeyGenerator
    -
    -      hashTable match {
    -        case unsafe: UnsafeHashedRelation =>
    -          TaskContext.get().internalMetricsToAccumulators(
    -            
InternalAccumulator.PEAK_EXECUTION_MEMORY).add(unsafe.getUnsafeSize)
    -        case _ =>
    -      }
    -
    -      val resultProj = resultProjection
    -      joinType match {
    -        case LeftOuter =>
    -          streamedIter.flatMap(currentRow => {
    -            val rowKey = keyGenerator(currentRow)
    -            joinedRow.withLeft(currentRow)
    -            leftOuterIterator(rowKey, joinedRow, hashTable.get(rowKey), 
resultProj)
    -          })
    -
    -        case RightOuter =>
    -          streamedIter.flatMap(currentRow => {
    -            val rowKey = keyGenerator(currentRow)
    -            joinedRow.withRight(currentRow)
    -            rightOuterIterator(rowKey, hashTable.get(rowKey), joinedRow, 
resultProj)
    -          })
    -
    -        case x =>
    -          throw new IllegalArgumentException(
    -            s"BroadcastHashOuterJoin should not take $x as the JoinType")
    -      }
    -    }
    -  }
    -}
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.sql.execution.joins
    +
    +import scala.concurrent._
    +import scala.concurrent.duration._
    +
    +import org.apache.spark.annotation.DeveloperApi
    +import org.apache.spark.rdd.RDD
    +import org.apache.spark.sql.catalyst.InternalRow
    +import org.apache.spark.sql.catalyst.expressions._
    +import org.apache.spark.sql.catalyst.plans.physical.{Distribution, 
Partitioning, UnspecifiedDistribution}
    +import org.apache.spark.sql.catalyst.plans.{JoinType, LeftOuter, 
RightOuter}
    +import org.apache.spark.sql.execution.{BinaryNode, SQLExecution, SparkPlan}
    +import org.apache.spark.{InternalAccumulator, TaskContext}
    +
    +/**
    + * :: DeveloperApi ::
    + * Performs a outer hash join for two child relations.  When the output 
RDD of this operator is
    + * being constructed, a Spark job is asynchronously started to calculate 
the values for the
    + * broadcasted relation.  This data is then placed in a Spark broadcast 
variable.  The streamed
    + * relation is not shuffled.
    + */
    +@DeveloperApi
    +case class BroadcastHashOuterJoin(
    +    leftKeys: Seq[Expression],
    +    rightKeys: Seq[Expression],
    +    joinType: JoinType,
    +    condition: Option[Expression],
    +    left: SparkPlan,
    +    right: SparkPlan) extends BinaryNode with OuterJoin {
    +
    +  val timeout = {
    +    val timeoutValue = sqlContext.conf.broadcastTimeout
    +    if (timeoutValue < 0) {
    +      Duration.Inf
    +    } else {
    +      timeoutValue.seconds
    +    }
    +  }
    +
    +  override def requiredChildDistribution: Seq[Distribution] =
    --- End diff --
    
    I'll just remove this here, since my EnsureRequirements patch is getting 
added later.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to