You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2018/12/23 01:01:53 UTC

[GitHub] gatorsmile closed pull request #20747: [SPARK-23609][SQL][TEST]Test EnsureRequirements's test cases to eliminate ShuffleExchange while is not expected

gatorsmile closed pull request #20747: [SPARK-23609][SQL][TEST]Test EnsureRequirements's test cases to eliminate ShuffleExchange while is not expected
URL: https://github.com/apache/spark/pull/20747
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala b/sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala
index f8b26f5b28cc7..1d3c10d432cf8 100644
--- a/sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala
+++ b/sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala
@@ -292,6 +292,9 @@ class PlannerSuite extends SharedSQLContext {
     )
     val outputPlan = EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
     assertDistributionRequirementsAreSatisfied(outputPlan)
+    if (outputPlan.collect { case e: ShuffleExchangeExec => true }.isEmpty) {
+      fail(s"Exchange should have been added:\n$outputPlan")
+    }
   }
 
   test("EnsureRequirements with compatible child partitionings that do not satisfy distribution") {
@@ -359,9 +362,7 @@ class PlannerSuite extends SharedSQLContext {
   }
 
   test("EnsureRequirements eliminates Exchange if child has same partitioning") {
-    val distribution = ClusteredDistribution(Literal(1) :: Nil)
     val partitioning = HashPartitioning(Literal(1) :: Nil, 5)
-    assert(partitioning.satisfies(distribution))
 
     val inputPlan = ShuffleExchangeExec(
       partitioning,
@@ -369,23 +370,22 @@ class PlannerSuite extends SharedSQLContext {
       None)
     val outputPlan = EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
     assertDistributionRequirementsAreSatisfied(outputPlan)
-    if (outputPlan.collect { case e: ShuffleExchangeExec => true }.size == 2) {
+    if (outputPlan.collect { case e: ShuffleExchangeExec => true }.nonEmpty) {
       fail(s"Topmost Exchange should have been eliminated:\n$outputPlan")
     }
   }
 
   test("EnsureRequirements does not eliminate Exchange with different partitioning") {
-    val distribution = ClusteredDistribution(Literal(1) :: Nil)
+    val childPartitioning = HashPartitioning(Literal(1) :: Nil, 5)
     val partitioning = HashPartitioning(Literal(2) :: Nil, 5)
-    assert(!partitioning.satisfies(distribution))
 
     val inputPlan = ShuffleExchangeExec(
       partitioning,
-      DummySparkPlan(outputPartitioning = partitioning),
+      DummySparkPlan(outputPartitioning = childPartitioning),
       None)
     val outputPlan = EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
     assertDistributionRequirementsAreSatisfied(outputPlan)
-    if (outputPlan.collect { case e: ShuffleExchangeExec => true }.size == 1) {
+    if (outputPlan.collect { case e: ShuffleExchangeExec => true }.isEmpty) {
       fail(s"Topmost Exchange should not have been eliminated:\n$outputPlan")
     }
   }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

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