Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/11190#discussion_r53514637
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkPlan.scala ---
@@ -122,7 +125,42 @@ abstract class SparkPlan extends QueryPlan[SparkPlan]
with Logging with Serializ
final def prepare(): Unit = {
if (prepareCalled.compareAndSet(false, true)) {
doPrepare()
+
+ // collect all the subqueries and submit jobs to execute them in
background
+ val queryResults = ArrayBuffer[(ScalarSubquery,
Future[Array[InternalRow]])]()
+ val allSubqueries = expressions.flatMap(_.collect {case e:
ScalarSubquery => e})
+ allSubqueries.foreach { e =>
+ val futureResult = scala.concurrent.future {
+ val df = DataFrame(sqlContext, e.query)
+ df.queryExecution.toRdd.collect()
+ }(SparkPlan.subqueryExecutionContext)
+ queryResults += e -> futureResult
+ }
+
children.foreach(_.prepare())
+
+ val timeout: Duration = {
+ val timeoutValue = sqlContext.conf.broadcastTimeout
+ if (timeoutValue < 0) {
+ Duration.Inf
+ } else {
+ timeoutValue.seconds
+ }
+ }
+
+ // fill in the result of subqueries
+ queryResults.foreach {
+ case (e, futureResult) =>
+ val rows = Await.result(futureResult, timeout)
--- End diff --
This timeout is kind of weird right? Like the max timeout here is
`numberOfSubqueries * timeout`?
---
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]