Github user cloud-fan commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17331#discussion_r106775256
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala ---
    @@ -557,6 +470,130 @@ class PlannerSuite extends SharedSQLContext {
           fail(s"Should have only two shuffles:\n$outputPlan")
         }
       }
    +
    +  
///////////////////////////////////////////////////////////////////////////
    +  // Unit tests of EnsureRequirements for Sort
    +  
///////////////////////////////////////////////////////////////////////////
    +
    +  private val exprA = Literal(1)
    +  private val exprB = Literal(2)
    +  private val orderingA = SortOrder(exprA, Ascending)
    +  private val orderingB = SortOrder(exprB, Ascending)
    +  private val planA = DummySparkPlan(outputOrdering = Seq(orderingA),
    +    outputPartitioning = HashPartitioning(exprA :: Nil, 5))
    +  private val planB = DummySparkPlan(outputOrdering = Seq(orderingB),
    +    outputPartitioning = HashPartitioning(exprB :: Nil, 5))
    +
    +  assert(orderingA != orderingB)
    +
    +  private def assertSortRequirementsAreSatisfied(
    +      childPlan: SparkPlan,
    +      requiredOrdering: Seq[SortOrder],
    +      shouldHaveSort: Boolean): Unit = {
    +    val inputPlan = DummySparkPlan(
    +      children = childPlan :: Nil,
    +      requiredChildOrdering = Seq(requiredOrdering),
    +      requiredChildDistribution = Seq(UnspecifiedDistribution)
    +    )
    +    val outputPlan = 
EnsureRequirements(spark.sessionState.conf).apply(inputPlan)
    +    assertDistributionRequirementsAreSatisfied(outputPlan)
    +    if (shouldHaveSort) {
    +      if (outputPlan.collect { case s: SortExec => true }.isEmpty) {
    +        fail(s"Sort should have been added:\n$outputPlan")
    +      }
    +    } else {
    +      if (outputPlan.collect { case s: SortExec => true }.nonEmpty) {
    +        fail(s"No sorts should have been added:\n$outputPlan")
    +      }
    +    }
    +  }
    +
    +  test("EnsureRequirements for sort operator after left outer sort merge 
join") {
    --- End diff --
    
    are we just moving test around?


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to