Skip to content

Commit

Permalink
Refine
Browse files Browse the repository at this point in the history
  • Loading branch information
PHILO-HE committed Sep 10, 2024
1 parent d87bd99 commit d6e117d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ abstract class BroadcastNestedLoopJoinExecTransformer(
override def rightKeys: Seq[Expression] = Nil

private lazy val substraitJoinType: CrossRel.JoinType =
SubstraitUtil.toCrossRelSubstrait(joinType, buildSide)
SubstraitUtil.toCrossRelSubstrait(joinType, needSwitchChildren)

// Unique ID for builded table
// Unique ID for built table.
lazy val buildBroadcastTableId: String = "BuiltBNLJBroadcastTable-" + buildPlan.id

// Hint substrait to switch the left and right,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import org.apache.gluten.substrait.SubstraitContext
import org.apache.gluten.substrait.expression.ExpressionNode

import org.apache.spark.sql.catalyst.expressions.{Attribute, Expression}
import org.apache.spark.sql.catalyst.optimizer.{BuildLeft, BuildRight, BuildSide}
import org.apache.spark.sql.catalyst.plans.{FullOuter, InnerLike, JoinType, LeftAnti, LeftOuter, LeftSemi, RightOuter}

import io.substrait.proto.{CrossRel, JoinRel}
Expand All @@ -50,22 +49,24 @@ object SubstraitUtil {
JoinRel.JoinType.UNRECOGNIZED
}

def toCrossRelSubstrait(sparkJoin: JoinType, buildSide: BuildSide): CrossRel.JoinType =
def toCrossRelSubstrait(sparkJoin: JoinType, needSwitchChildren: Boolean): CrossRel.JoinType =
sparkJoin match {
case _: InnerLike =>
CrossRel.JoinType.JOIN_TYPE_INNER
case LeftOuter =>
// since we always assume build right side in substrait,
// the left and right relations are exchanged and the
// join type is reverted.
buildSide match {
case BuildLeft => CrossRel.JoinType.JOIN_TYPE_RIGHT
case BuildRight => CrossRel.JoinType.JOIN_TYPE_LEFT
if (needSwitchChildren) {
CrossRel.JoinType.JOIN_TYPE_RIGHT
} else {
CrossRel.JoinType.JOIN_TYPE_LEFT
}
case RightOuter =>
buildSide match {
case BuildRight => CrossRel.JoinType.JOIN_TYPE_RIGHT
case BuildLeft => CrossRel.JoinType.JOIN_TYPE_LEFT
if (needSwitchChildren) {
CrossRel.JoinType.JOIN_TYPE_LEFT
} else {
CrossRel.JoinType.JOIN_TYPE_RIGHT
}
case LeftSemi =>
CrossRel.JoinType.JOIN_TYPE_LEFT_SEMI
Expand Down

0 comments on commit d6e117d

Please sign in to comment.