Github user wzhfy commented on a diff in the pull request:

    https://github.com/apache/spark/pull/20560#discussion_r180390730
  
    --- Diff: 
sql/core/src/test/scala/org/apache/spark/sql/execution/PlannerSuite.scala ---
    @@ -197,6 +198,19 @@ class PlannerSuite extends SharedSQLContext {
         assert(planned.child.isInstanceOf[CollectLimitExec])
       }
     
    +  test("SPARK-23375: Cached sorted data doesn't need to be re-sorted") {
    +    val query = testData.select('key, 'value).sort('key.desc).cache()
    +    
assert(query.queryExecution.optimizedPlan.isInstanceOf[InMemoryRelation])
    +    val resorted = query.sort('key.desc)
    +    assert(resorted.queryExecution.optimizedPlan.collect { case s: Sort => 
s}.isEmpty)
    +    assert(resorted.select('key).collect().map(_.getInt(0)).toSeq ==
    +      (1 to 100).sorted(Ordering[Int].reverse))
    --- End diff --
    
    `(1 to 100).reverse`?


---

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

Reply via email to