Uh oh!
There was an error while loading. Please reload this page.
[SPARK-27393][SQL] Show ReusedSubquery in the plan when the subquery is reused - #24258
[SPARK-27393][SQL] Show ReusedSubquery in the plan when the subquery is reused#24258gatorsmile wants to merge 3 commits into
Conversation
| } | ||
| } | ||
| test("Reuse Subquery") { |
There was a problem hiding this comment.
moved to SubquerySuite.scala
SparkQA
commented
Mar 31, 2019
Test build #104128 has finished for PR 24258 at commit
|
SparkQA
commented
Mar 31, 2019
Test build #104127 has finished for PR 24258 at commit
|
adrian-wang
commented
Mar 31, 2019
retest this please. |
SparkQA
commented
Mar 31, 2019
Test build #104138 has finished for PR 24258 at commit
|
| val normalizedPlan = plan.transformAllExpressions { | ||
| case OuterReference(r) => OuterReference(QueryPlan.normalizeExprId(r, attrs)) | ||
| } | ||
| }.canonicalized |
There was a problem hiding this comment.
We need to the canonicalized plan here? It seems all the canonicalization should happen in line 69?
| import org.apache.spark.scheduler.{SparkListener, SparkListenerJobStart} | ||
| import org.apache.spark.sql.catalyst.util.StringUtils | ||
| import org.apache.spark.sql.execution.{aggregate, ScalarSubquery, SubqueryExec} | ||
| import org.apache.spark.sql.execution.aggregate |
There was a problem hiding this comment.
nit: we can remove this import by changing aggregate.HashAggregateExec -> HashAggregateExec in line 263?
| override def executeCollect(): Array[InternalRow] = { | ||
| child.executeCollect() | ||
| } |
There was a problem hiding this comment.
super nit:
protected override def doPrepare(): Unit = child.prepare()
protected override def doExecute(): RDD[InternalRow] = child.execute()
override def executeCollect(): Array[InternalRow] = child.executeCollect()
maropu
commented
Apr 1, 2019
btw, is it not worth filing a new jira for this refactoring? |
| "dataSize" -> SQLMetrics.createSizeMetric(sparkContext, "data size"), | ||
| "collectTime" -> SQLMetrics.createTimingMetric(sparkContext, "time to collect")) | ||
| abstract class BaseSubqueryExec extends SparkPlan { | ||
| def name: String |
There was a problem hiding this comment.
We need name in this base class for subquery exec?
There was a problem hiding this comment.
both ReusedSubqueryExec and SubqueryExec have the name
| case sub: ExecSubqueryExpression => | ||
| val sameSchema = subqueries.getOrElseUpdate(sub.plan.schema, ArrayBuffer[SubqueryExec]()) | ||
| val sameSchema = | ||
| subqueries.getOrElseUpdate(sub.plan.schema, ArrayBuffer[BaseSubqueryExec]()) |
There was a problem hiding this comment.
change it to BaseSubqueryExec
cloud-fan
commented
Apr 1, 2019
Shall we create a new JIRA? This improves the SQL web UI |
SubqueryExecSparkQA
commented
Apr 5, 2019
Test build #104306 has finished for PR 24258 at commit
|
SparkQA
commented
Apr 5, 2019
Test build #4691 has finished for PR 24258 at commit
|
maropu
commented
Apr 5, 2019
retest this please |
SparkQA
commented
Apr 5, 2019
Test build #104314 has finished for PR 24258 at commit
|
gatorsmile
commented
Apr 5, 2019
Thanks! Merged to master. |
…is reused With this change, we can easily identify the plan difference when subquery is reused. When the reuse is enabled, the plan looks like ``` == Physical Plan == CollectLimit 1 +- *(1) Project [(Subquery subquery240 + ReusedSubquery Subquery subquery240) AS (scalarsubquery() + scalarsubquery())#253] : :- Subquery subquery240 : : +- *(2) HashAggregate(keys=[], functions=[avg(cast(key#13 as bigint))], output=[avg(key)#250]) : : +- Exchange SinglePartition : : +- *(1) HashAggregate(keys=[], functions=[partial_avg(cast(key#13 as bigint))], output=[sum#256, count#257L]) : : +- *(1) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#13] : : +- Scan[obj#12] : +- ReusedSubquery Subquery subquery240 +- *(1) SerializeFromObject +- Scan[obj#12] ``` When the reuse is disabled, the plan looks like ``` == Physical Plan == CollectLimit 1 +- *(1) Project [(Subquery subquery286 + Subquery subquery287) AS (scalarsubquery() + scalarsubquery())#299] : :- Subquery subquery286 : : +- *(2) HashAggregate(keys=[], functions=[avg(cast(key#13 as bigint))], output=[avg(key)#296]) : : +- Exchange SinglePartition : : +- *(1) HashAggregate(keys=[], functions=[partial_avg(cast(key#13 as bigint))], output=[sum#302, count#303L]) : : +- *(1) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#13] : : +- Scan[obj#12] : +- Subquery subquery287 : +- *(2) HashAggregate(keys=[], functions=[avg(cast(key#13 as bigint))], output=[avg(key)#298]) : +- Exchange SinglePartition : +- *(1) HashAggregate(keys=[], functions=[partial_avg(cast(key#13 as bigint))], output=[sum#306, count#307L]) : +- *(1) SerializeFromObject [knownnotnull(assertnotnull(input[0, org.apache.spark.sql.test.SQLTestData$TestData, true])).key AS key#13] : +- Scan[obj#12] +- *(1) SerializeFromObject +- Scan[obj#12] ``` Modified the existing test. Closesapache#24258 from gatorsmile/followupSPARK-27279. Authored-by: gatorsmile <gatorsmile@gmail.com> Signed-off-by: gatorsmile <gatorsmile@gmail.com>
What changes were proposed in this pull request?
With this change, we can easily identify the plan difference when subquery is reused.
When the reuse is enabled, the plan looks like
When the reuse is disabled, the plan looks like
How was this patch tested?
Modified the existing test.