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

    https://github.com/apache/spark/pull/15596#discussion_r84579127
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/limit.scala ---
    @@ -36,14 +36,14 @@ import org.apache.spark.util.Utils
     case class CollectLimitExec(limit: Int, child: SparkPlan) extends 
UnaryExecNode {
       override def output: Seq[Attribute] = child.output
       override def outputPartitioning: Partitioning = SinglePartition
    -  override def executeCollect(): Array[InternalRow] = 
child.executeTake(limit)
    -  private val serializer: Serializer = new 
UnsafeRowSerializer(child.output.size)
    +  override def requiredChildDistribution: List[Distribution] = AllTuples 
:: Nil
    +  override def executeCollect(): Array[InternalRow] = child match {
    +    case e: Exchange => e.child.executeTake(limit)
    +    case _ => child.executeTake(limit)
    +  }
    +
       protected override def doExecute(): RDD[InternalRow] = {
    -    val locallyLimited = 
child.execute().mapPartitionsInternal(_.take(limit))
    --- End diff --
    
    We are removing an optimization here right? We can greatly reduce the 
number of shuffled records by applying the limit before anything gets shuffled.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to