LukaZdravic commented on code in PR #60029:
URL: https://github.com/apache/spark/pull/60029#discussion_r4455116661


##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeAsOfJoinExec.scala:
##########
@@ -161,17 +161,20 @@ private[joins] class SortMergeAsOfJoinScanner(
   private val joinedOutput = leftOutput ++ rightOutput
   private val joinedRow = new JoinedRow()
   // Use nullable bound references so outer-join null padding is safe even when
-  // right attributes are NOT NULL in the catalog schema.
+  // right attributes are NOT NULL in the catalog schema. Every output row 
reuses the
+  // projection's row.
   private val resultProjection = {
     val nullableRefs = joinedOutput.zipWithIndex.map { case (attr, i) =>
       BoundReference(i, attr.dataType, nullable = true)
     }
     UnsafeProjection.create(nullableRefs, joinedOutput)
   }
 
-  private val boundAsOfCond = bindReference(asOfCondition, joinedOutput)
+  // Compiled once, so a check runs generated code instead of walking the 
expression tree.
+  // The scan checks the as-of condition for every right row it reads.
+  private val boundAsOfCond = Predicate.create(asOfCondition, joinedOutput)
   private val boundResidualCond =
-    residualCondition.map(bindReference(_, joinedOutput))
+    residualCondition.map(Predicate.create(_, joinedOutput))

Review Comment:
   Fixed with `useSubexprElimination = false` within my own created object, 
thanks and good catch!



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

Reply via email to