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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to