Github user gczsjdy commented on a diff in the pull request: https://github.com/apache/spark/pull/19862#discussion_r156581645 --- Diff: sql/catalyst/src/main/java/org/apache/spark/sql/execution/UnsafeExternalRowSorter.java --- @@ -159,6 +154,12 @@ public boolean hasNext() { @Override public UnsafeRow next() { try { + if (!alreadyCalculated) { + while (inputIterator.hasNext()) { + insertRow(inputIterator.next()); + } + alreadyCalculated = true; + } sortedIterator.loadNext(); --- End diff -- Yes, you are right. Now I modified the `sortedIterator` after inserting rows. Due to I can only access an outer final field inside an inner class, so I used an array, is there better solution?
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org