wangyum commented on code in PR #37118:
URL: https://github.com/apache/spark/pull/37118#discussion_r916916958


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala:
##########
@@ -283,20 +283,7 @@ case class TakeOrderedAndProjectExec(
   }
 
   override def executeCollect(): Array[InternalRow] = {
-    val orderingSatisfies = SortOrder.orderingSatisfies(child.outputOrdering, 
sortOrder)
-    val ord = new LazilyGeneratedOrdering(sortOrder, child.output)
-    val limited = if (orderingSatisfies) {
-      
child.execute().mapPartitionsInternal(_.map(_.copy()).take(limit)).takeOrdered(limit)(ord)
-    } else {
-      
child.execute().mapPartitionsInternal(_.map(_.copy())).takeOrdered(limit)(ord)

Review Comment:
   No. The result does not match if it contains duplicate values. For example, 
order by column a:
   
   ```
   +---+---+
   |  a|  b|
   +---+---+
   |  1|  1|
   |  1|  2|
   |  2|  3|
   |  2|  4|
   |  3|  5|
   |  3|  6|
   +---+---+
   ```



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to