Github user rxin commented on a diff in the pull request:
https://github.com/apache/spark/pull/11083#discussion_r53563543
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange.scala ---
@@ -261,10 +266,71 @@ object Exchange {
}
/**
+ * A [[BroadcastExchange]] collects, transforms and finally broadcasts the
result of a transformed
+ * SparkPlan.
+ */
+case class BroadcastExchange(
+ mode: BroadcastMode,
+ child: SparkPlan) extends UnaryNode {
+
+ override def output: Seq[Attribute] = child.output
+
+ override def outputPartitioning: Partitioning =
BroadcastPartitioning(mode)
+
+ val timeout: Duration = {
+ val timeoutValue = sqlContext.conf.broadcastTimeout
+ if (timeoutValue < 0) {
+ Duration.Inf
+ } else {
+ timeoutValue.seconds
+ }
+ }
+
+ @transient
+ private lazy val relationFuture: Future[broadcast.Broadcast[Any]] = {
+ // 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] = child.execute().map { row =>
+ row.copy()
+ }.collect()
+
+ // Construct and broadcast the relation.
+ sparkContext.broadcast(mode.transform(input))
+ }
+ }(BroadcastExchange.executionContext)
+ }
+
+ override protected def doPrepare(): Unit = {
+ // Materialize the future.
+ relationFuture
+ }
+
+ override protected def doExecute(): RDD[InternalRow] = {
+ throw new UnsupportedOperationException("Broadcast does not support
the execute() code path.")
--- End diff --
Broadcast -> BroadcastExchange, or maybe just use
"getClass.getName"
---
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]