@@ -654,8 +654,10 @@ case class SortMergeJoinExec(
654
654
(evaluateVariables(leftVars), " " )
655
655
}
656
656
657
- // The last two line of code generate in processNext here will handle properly
658
- // releasing the resources if the input iterators are not fully consumed
657
+ // The last two lines of code generated in processNext here will attempt to handle
658
+ // releasing the resources if the input iterators are not fully consumed. It only
659
+ // attempts to release the resources of an iterator if the associated child operator
660
+ // is codegened
659
661
s """
660
662
|while (findNextInnerJoinRows( $leftInput, $rightInput)) {
661
663
| ${leftVarDecl.mkString(" \n " )}
@@ -669,10 +671,16 @@ case class SortMergeJoinExec(
669
671
| }
670
672
| if (shouldStop()) return;
671
673
|}
672
- |((org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) $leftInput)
673
- | .getBufferedRowIterator().close();
674
- |((org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) $rightInput)
675
- | .getBufferedRowIterator().close();
674
+ |if ( $leftInput instanceof
675
+ | org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) {
676
+ | ((org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) $leftInput)
677
+ | .getBufferedRowIterator().close();
678
+ |}
679
+ |if ( $rightInput instanceof
680
+ | org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) {
681
+ | ((org.apache.spark.sql.execution.ScalaIteratorWithBufferedIterator) $rightInput)
682
+ | .getBufferedRowIterator().close();
683
+ |}
676
684
""" .stripMargin
677
685
}
678
686
}
0 commit comments