Github user marmbrus commented on a diff in the pull request:
https://github.com/apache/spark/pull/3531#discussion_r21129941
--- Diff:
sql/core/src/main/scala/org/apache/spark/sql/execution/basicOperators.scala ---
@@ -148,20 +148,15 @@ case class Limit(limit: Int, child: SparkPlan)
}
override def execute() = {
- val rdd: RDD[_ <: Product2[Boolean, Row]] = if (sortBasedShuffleOn) {
- child.execute().mapPartitions { iter =>
- iter.take(limit).map(row => (false, row.copy()))
+ if (sortBasedShuffleOn) {
+ child.execute().map(_.copy).coalesce(1).mapPartitions { iter =>
+ iter.take(limit)
--- End diff --
You do need to `copy()` before any `take` or `collect` operation because
SparkSQL will reuse row objects and these operations create arrays that will
end up all containing the same object.
---
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]