[SPARK-6872] [SQL] add copy in external sort

We need add copy before call externalsort.

Author: Daoyuan Wang <daoyuan.wang@intel.com>

Closes #5481 from adrian-wang/extsort and squashes the following commits:

9611586 [Daoyuan Wang] fix bug in external sort
This commit is contained in:
Daoyuan Wang 2015-04-13 16:00:58 -07:00 committed by Michael Armbrust
parent 2a55cb41bf
commit e63a86abe2

View file

@ -194,7 +194,7 @@ case class ExternalSort(
child.execute().mapPartitions( { iterator =>
val ordering = newOrdering(sortOrder, child.output)
val sorter = new ExternalSorter[Row, Null, Row](ordering = Some(ordering))
sorter.insertAll(iterator.map(r => (r, null)))
sorter.insertAll(iterator.map(r => (r.copy, null)))
val baseIterator = sorter.iterator.map(_._1)
// TODO(marmbrus): The complex type signature below thwarts inference for no reason.
CompletionIterator[Row, Iterator[Row]](baseIterator, sorter.stop())