diff --git a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/execution/GpuBroadcastNestedLoopJoinExecBase.scala b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/execution/GpuBroadcastNestedLoopJoinExecBase.scala index 578c1106eb1..b939a8c4155 100644 --- a/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/execution/GpuBroadcastNestedLoopJoinExecBase.scala +++ b/sql-plugin/src/main/scala/org/apache/spark/sql/rapids/execution/GpuBroadcastNestedLoopJoinExecBase.scala @@ -658,11 +658,15 @@ abstract class GpuBroadcastNestedLoopJoinExecBase( localJoinType match { case LeftOuter if spillableBuiltBatch.numRows == 0 => - new EmptyOuterNestedLoopJoinIterator(streamedIter, spillableBuiltBatch.dataTypes, - true) + withResource(spillableBuiltBatch) { _ => + new EmptyOuterNestedLoopJoinIterator(streamedIter, spillableBuiltBatch.dataTypes, + true) + } case RightOuter if spillableBuiltBatch.numRows == 0 => - new EmptyOuterNestedLoopJoinIterator(streamedIter, spillableBuiltBatch.dataTypes, - false) + withResource(spillableBuiltBatch) { _ => + new EmptyOuterNestedLoopJoinIterator(streamedIter, spillableBuiltBatch.dataTypes, + false) + } case _ => new CrossJoinIterator( spillableBuiltBatch,