LukaZdravic commented on code in PR #59102:
URL: https://github.com/apache/spark/pull/59102#discussion_r4142637127
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeAsOfJoinExec.scala:
##########
@@ -92,34 +92,26 @@ case class SortMergeAsOfJoinExec(
override def outputOrdering: Seq[SortOrder] = left.outputOrdering
- // Backward joins scan the right-side buffer forward and keep the last match.
- // Detect from asOfCondition so composite MATCH_CONDITION sort keys still
work.
- private val isBackwardJoin: Boolean =
- isBackwardAsOfCondition(asOfCondition, left.output, right.output)
-
- private def isBackwardAsOfCondition(
- condition: Expression,
- leftOutput: Seq[Attribute],
- rightOutput: Seq[Attribute]): Boolean = {
- val leftAttrs = AttributeSet(leftOutput)
- val rightAttrs = AttributeSet(rightOutput)
- def isBackwardPredicate(expr: Expression): Boolean = expr match {
- case GreaterThanOrEqual(l, r)
- if l.references.subsetOf(leftAttrs) &&
r.references.subsetOf(rightAttrs) =>
- true
- case GreaterThan(l, r)
- if l.references.subsetOf(leftAttrs) &&
r.references.subsetOf(rightAttrs) =>
- true
- case And(c, _) => isBackwardPredicate(c)
- case _ => false
+ // Detect from asOfCondition so composite MATCH_CONDITION sort keys still
work. Only a first
+ // `left op right` conjunct counts. Nearest has none: its condition is TRUE,
NOT(l = r), or
+ // starts with `right >= left - tolerance`.
Review Comment:
Addressed, thanks!
##########
sql/core/src/main/scala/org/apache/spark/sql/execution/joins/SortMergeAsOfJoinExec.scala:
##########
@@ -207,7 +197,8 @@ private[joins] class SortMergeAsOfJoinScanner(
private val leftKeyProj = UnsafeProjection.create(leftKeys, leftOutput)
private val rightKeyProj = UnsafeProjection.create(rightKeys, rightOutput)
- private val distanceOrdering =
+ // Lazy for the same reason as boundOrderExpr.
+ private lazy val distanceOrdering =
Review Comment:
Moved, thanks!
--
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]