dongjoon-hyun commented on code in PR #60537:
URL: https://github.com/apache/spark/pull/60537#discussion_r4581426955


##########
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:
   Thank you for the review, @viirya. Yes, you're right. The join's own right 
group buffer is held until the task ends in both the interpreted and the 
generated scans, and `close()` would count the spill size twice since 
`ExternalAppendOnlyUnsafeRowArray.spillSize` is cumulative. Since the generated 
scan needs the same change, and the test needs a spill-backed buffer to observe 
it (the in-memory buffer is not counted as execution memory), let me handle it 
in a new JIRA issue.



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

Reply via email to