c21 commented on a change in pull request #32528:
URL: https://github.com/apache/spark/pull/32528#discussion_r631610541



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala
##########
@@ -424,8 +424,18 @@ case class SortMergeJoinExec(
     // A list to hold all matched rows from buffered side.
     val clsName = classOf[ExternalAppendOnlyUnsafeRowArray].getName
 
+    // Flag to only buffer first matched row, to avoid buffering unnecessary 
rows.
+    val onlyBufferFirstMatchedRow = (joinType, condition) match {
+      case (LeftSemi, None) => true
+      case _ => false
+    }
+    val inMemoryThreshold =
+      if (onlyBufferFirstMatchedRow) {

Review comment:
       Good call. Actually the non-code-gen path can also depend on this, so I 
make it just a `val` now.




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

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to