viirya commented on code in PR #60537:
URL: https://github.com/apache/spark/pull/60537#discussion_r4581195490
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeAsOfJoinExec.scala:
##########
@@ -127,7 +129,10 @@ case class SortMergeAsOfJoinExec(
useCursorScan, numAsOfCursorTasks
)
TaskContext.get().addTaskCompletionListener[Unit](_ => scanner.close())
- scanner.iterator
+ // Like the generated join, release the sorters below once the left side
is done, instead of
+ // holding their memory until the task completes.
+ CompletionIterator[InternalRow, Iterator[InternalRow]](
+ scanner.iterator, taskResourceCleaners.foreach(_.cleanupResources()))
Review Comment:
Since this now releases resources once the left side is done: the join's own
`rightGroupBuffer` (and `rightGroup` in the generated scan) is still held until
the task ends. Without equi-keys, that buffer holds the whole right side.
`SortMergeJoinScanner` clears `bufferedMatches` at this point. Should we do the
same here, maybe in a follow-up? It would need `rightGroupBuffer.clear()`, not
`scanner.close()`, since the task completion listener calls `close()` again and
the spill size would be counted twice.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]