Github user xwu0226 commented on a diff in the pull request: https://github.com/apache/spark/pull/14842#discussion_r77227594 --- Diff: core/src/main/java/org/apache/spark/util/collection/unsafe/sort/UnsafeInMemorySorter.java --- @@ -333,11 +333,12 @@ public UnsafeSorterIterator getSortedIterator() { if (nullBoundaryPos > 0) { assert radixSortSupport != null : "Nulls are only stored separately with radix sort"; LinkedList<UnsafeSorterIterator> queue = new LinkedList<>(); - if (radixSortSupport.sortDescending()) { - // Nulls are smaller than non-nulls + + // The null order is either LAST or FIRST, regardless of sorting direction (ASC|DESC) + if (radixSortSupport.nullOrder() == PrefixComparator.NullOrder.LAST) { queue.add(new SortedIterator((pos - nullBoundaryPos) / 2, offset)); queue.add(new SortedIterator(nullBoundaryPos / 2, 0)); - } else { + } else if (radixSortSupport.nullOrder() == PrefixComparator.NullOrder.FIRST) { queue.add(new SortedIterator(nullBoundaryPos / 2, 0)); queue.add(new SortedIterator((pos - nullBoundaryPos) / 2, offset)); } --- End diff -- I think one of the reasons I need to modify the `PrefixComparators` code is because` `UnsafeInMemorySorter` here puts null rows in a separate queue that is appended to before or after the non-null queue depending on sort direction ASC|DESC.
--- 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 infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org