dongjoon-hyun opened a new pull request, #60537: URL: https://github.com/apache/spark/pull/60537
### What changes were proposed in this pull request? This PR makes the interpreted path of `SortMergeAsOfJoinExec` release the sorters of the sorts below it once the scan has produced its last row (the left side is done), as its generated path already does since SPARK-61666. `doExecute` takes `TaskResourceCleaner.inStage(this)` on the driver, and wraps the scanner's iterator in a `CompletionIterator` that calls `cleanupResources()` on those cleaners. It uses the cleaners rather than calling `cleanupResources()` on the child plans, so that the closure does not need the child plans in the task. The interpreted path runs for the `nearest` direction (it has no generated scan), when `spark.sql.codegen.wholeStage` is `false`, or when the join output has more fields than `spark.sql.codegen.maxFields`. ### Why are the changes needed? The interpreted join never released the sorters of the sorts below it. When the left side ends before the right side, the right sorter keeps its memory until the task completes. In the new test, a task still held 67,174,384 bytes of execution memory after reading the join to its end. ### Does this PR introduce _any_ user-facing change? No. The join returns the same rows; the right sorter's memory is released earlier. ### How was this patch tested? Pass the CIs with the newly added test case, which reads a nearest join, whose right side has keys above every left key, to its end in a task, and checks that the task holds no execution memory afterwards. It fails without this change. ``` $ build/sbt 'sql/testOnly org.apache.spark.sql.SortMergeAsOfJoinSuite -- -z "SPARK-61756"' ``` ### Was this patch authored or co-authored using generative AI tooling? Generated-by: Claude Opus 5.5 -- 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]
