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



##########
File path: 
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeJoinExec.scala
##########
@@ -724,9 +749,32 @@ case class SortMergeJoinExec(
        """.stripMargin
     }
 
+    lazy val semiJoin = {

Review comment:
       How about extracting this block as a private method like `codegenXXXX` 
just like `HashJoin`?

##########
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:
       How about moving this branch into the `getInMemoryThreshold` side?
   ```
   
     // Flag to only buffer first matched row, to avoid buffering unnecessary 
rows.
     private lazy val onlyBufferFirstMatchedRow = (joinType, condition) match {
       case (LeftSemi, None) => true
       case _ => false
     }
   
     private def getInMemoryThreshold: Int = {
       if (onlyBufferFirstMatchedRow) {
         1
       } else {
         sqlContext.conf.sortMergeJoinExecBufferInMemoryThreshold
       }
     }
   ```




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