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

    https://github.com/apache/spark/pull/9330#discussion_r43249575
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/GroupedIterator.scala ---
    @@ -96,46 +97,64 @@ class GroupedIterator private(
         ret
       }
     
    -  def fetchNextGroupIterator(): Boolean = {
    -    if (currentRow != null || input.hasNext) {
    -      val inputIterator = new Iterator[InternalRow] {
    -        // Return true if we have a row and it is in the current group, or 
if fetching a new row is
    -        // successful.
    -        def hasNext = {
    -          (currentRow != null && keyOrdering.compare(currentGroup, 
currentRow) == 0) ||
    -            fetchNextRowInGroup()
    -        }
    +  private def fetchNextGroupIterator(): Boolean = {
    +    assert(currentIterator eq null)
    +
    +    if (currentRow.eq(null) && input.hasNext) {
    +      currentRow = input.next()
    +    }
    +
    +    if (currentRow eq null) {
    +      // These is no data left, return false.
    +      false
    +    } else {
    +      // Skip to next group.
    +      while (input.hasNext && keyOrdering.compare(currentGroup, 
currentRow) == 0) {
    +        currentRow = input.next()
    +      }
    +
    +      if (keyOrdering.compare(currentGroup, currentRow) == 0) {
    +        // These is no more group. return false.
    --- End diff --
    
    nit: "there" or maybe more clearly "we are no longer in the current group, 
return false."


---
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