Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update HashAggregateSuite to work with AQE #469

Merged
merged 2 commits into from
Jul 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import java.sql.Timestamp
import org.apache.spark.SparkConf
import org.apache.spark.sql.{AnalysisException, DataFrame, SparkSession}
import org.apache.spark.sql.execution.{SparkPlan, WholeStageCodegenExec}
import org.apache.spark.sql.execution.adaptive.{BroadcastQueryStageExec, QueryStageExec, ShuffleQueryStageExec}
import org.apache.spark.sql.execution.adaptive.{AdaptiveSparkPlanExec, BroadcastQueryStageExec, QueryStageExec, ShuffleQueryStageExec}
import org.apache.spark.sql.execution.aggregate.SortAggregateExec
import org.apache.spark.sql.functions._
import org.apache.spark.sql.types.{DataType, DataTypes}
Expand Down Expand Up @@ -120,13 +120,20 @@ class HashAggregatesSuite extends SparkQueryCompareTestSuite {
assert(cpuPlan.find(_.isInstanceOf[SortAggregateExec]).isDefined)

val gpuPlan = df.queryExecution.executedPlan
// execute the plan so that the final adaptive plan is available when AQE is on
df.collect()
revans2 marked this conversation as resolved.
Show resolved Hide resolved

gpuPlan match {
case WholeStageCodegenExec(GpuColumnarToRowExec(plan, _)) =>
assert(plan.children.head.isInstanceOf[GpuHashAggregateExec])
assert(gpuPlan.find(_.isInstanceOf[SortAggregateExec]).isEmpty)
assert(gpuPlan.children.forall(exec => exec.isInstanceOf[GpuExec]))

case a: AdaptiveSparkPlanExec =>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be good to revisit creating helper utilities for inspecting plans, that can work both with adaptive and non-adaptive plans so we don't end up with lots of duplicate code in tests. I don't think it has to be part of this PR though.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @andygrove . I have created a follow-on issue for creating helper utilities #476

assert(a.toString.startsWith("AdaptiveSparkPlan isFinalPlan=true"))
assert(a.executedPlan.find(_.isInstanceOf[SortAggregateExec]).isEmpty)
assert(a.executedPlan.children.forall(exec => exec.isInstanceOf[GpuExec]))

case _ =>
fail("Incorrect plan")
}
Expand All @@ -149,6 +156,8 @@ class HashAggregatesSuite extends SparkQueryCompareTestSuite {
assert(cpuPlan.find(_.isInstanceOf[SortAggregateExec]).isDefined)

val gpuPlan = df.queryExecution.executedPlan
// execute the plan so that the final adaptive plan is available when AQE is on
df.collect()
revans2 marked this conversation as resolved.
Show resolved Hide resolved

gpuPlan match {
case WholeStageCodegenExec(GpuColumnarToRowExec(plan, _)) =>
Expand All @@ -157,6 +166,12 @@ class HashAggregatesSuite extends SparkQueryCompareTestSuite {
assert(gpuPlan.find(_.isInstanceOf[GpuHashAggregateExec]).isDefined)
assert(gpuPlan.children.forall(exec => exec.isInstanceOf[GpuExec]))

case a: AdaptiveSparkPlanExec =>
assert(a.toString.startsWith("AdaptiveSparkPlan isFinalPlan=true"))
assert(a.executedPlan.find(_.isInstanceOf[GpuSortExec]).isDefined)
assert(a.executedPlan.find(_.isInstanceOf[SortAggregateExec]).isEmpty)
assert(a.executedPlan.children.forall(exec => exec.isInstanceOf[GpuExec]))

case _ =>
fail("Incorrect plan")
}
Expand Down