Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,16 @@ class ShimsImpl extends Shims with Logging {
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
joinType: JoinType,
buildSide: BuildSide): SparkPlan =
buildSide: BuildSide,
isSkewJoin: Boolean): SparkPlan =
NativeShuffledHashJoinExecProvider.provide(
left,
right,
leftKeys,
rightKeys,
joinType,
buildSide)
buildSide,
isSkewJoin)

override def createNativeExpandExec(
projections: Seq[Seq[Expression]],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ case object NativeShuffledHashJoinExecProvider {
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
joinType: JoinType,
buildSide: BuildSide): NativeShuffledHashJoinBase = {
buildSide: BuildSide,
isSkewJoin: Boolean): NativeShuffledHashJoinBase = {

import org.apache.spark.rdd.RDD
import org.apache.spark.sql.catalyst.InternalRow
Expand All @@ -44,7 +45,8 @@ case object NativeShuffledHashJoinExecProvider {
override val leftKeys: Seq[Expression],
override val rightKeys: Seq[Expression],
override val joinType: JoinType,
buildSide: BuildSide)
buildSide: BuildSide,
skewJoin: Boolean)
extends NativeShuffledHashJoinBase(left, right, leftKeys, rightKeys, joinType, buildSide)
with org.apache.spark.sql.execution.joins.ShuffledJoin {

Expand All @@ -70,9 +72,10 @@ case object NativeShuffledHashJoinExecProvider {
newRight: SparkPlan): SparkPlan =
copy(left = newLeft, right = newRight)

override def nodeName: String = "NativeShuffledHashJoinExec"
override def nodeName: String =
"NativeShuffledHashJoinExec" + (if (skewJoin) "(skew=true)" else "")
}
NativeShuffledHashJoinExec(left, right, leftKeys, rightKeys, joinType, buildSide)
NativeShuffledHashJoinExec(left, right, leftKeys, rightKeys, joinType, buildSide, isSkewJoin)
}

@sparkver("3.1")
Expand All @@ -82,7 +85,8 @@ case object NativeShuffledHashJoinExecProvider {
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
joinType: JoinType,
buildSide: BuildSide): NativeShuffledHashJoinBase = {
buildSide: BuildSide,
isSkewJoin: Boolean): NativeShuffledHashJoinBase = {

import org.apache.spark.sql.catalyst.expressions.SortOrder
import org.apache.spark.sql.execution.blaze.plan.BuildLeft
Expand Down Expand Up @@ -129,7 +133,8 @@ case object NativeShuffledHashJoinExecProvider {
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
joinType: JoinType,
buildSide: BuildSide): NativeShuffledHashJoinBase = {
buildSide: BuildSide,
isSkewJoin: Boolean): NativeShuffledHashJoinBase = {

import org.apache.spark.sql.catalyst.expressions.Attribute
import org.apache.spark.sql.execution.blaze.plan.BuildLeft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,12 @@ object BlazeConverters extends Logging {
getShuffleOrigin(exec))
}

@sparkver(" 3.2 / 3.3 / 3.4 / 3.5")
def getIsSkewJoinFromSHJ(exec: ShuffledHashJoinExec): Boolean = exec.isSkewJoin

@sparkver("3.0 / 3.1")
def getIsSkewJoinFromSHJ(exec: ShuffledHashJoinExec): Boolean = false

@sparkver("3.1 / 3.2 / 3.3 / 3.4 / 3.5")
def getShuffleOrigin(exec: ShuffleExchangeExec): Option[Any] = Some(exec.shuffleOrigin)

Expand Down Expand Up @@ -400,8 +406,15 @@ object BlazeConverters extends Logging {
if (!requireOrdering
&& BlazeConf.FORCE_SHUFFLED_HASH_JOIN.booleanConf()
&& exec.children.forall(_.isInstanceOf[NativeSortBase])) {
val (leftKeys, rightKeys, joinType, condition, left, right) =
(exec.leftKeys, exec.rightKeys, exec.joinType, exec.condition, exec.left, exec.right)
val (leftKeys, rightKeys, joinType, condition, left, right, isSkewJoin) =
(
exec.leftKeys,
exec.rightKeys,
exec.joinType,
exec.condition,
exec.left,
exec.right,
exec.isSkewJoin)
logDebug(
s"Converting SortMergeJoinExec (with forceShuffledHashJoin): ${Shims.get.simpleStringWithNodeId(exec)}")
logDebug(s" leftKeys: $leftKeys")
Expand All @@ -425,7 +438,8 @@ object BlazeConverters extends Logging {
leftKeys,
rightKeys,
joinType,
buildSide)
buildSide,
isSkewJoin)
}

val (leftKeys, rightKeys, joinType, condition, left, right, isSkewJoin) =
Expand Down Expand Up @@ -480,7 +494,8 @@ object BlazeConverters extends Logging {
buildSide match {
case BuildLeft => org.apache.spark.sql.execution.blaze.plan.BuildLeft
case BuildRight => org.apache.spark.sql.execution.blaze.plan.BuildRight
})
},
getIsSkewJoinFromSHJ(exec))

} catch {
case _ if BlazeConf.FORCE_SHUFFLED_HASH_JOIN.booleanConf() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ abstract class Shims {
leftKeys: Seq[Expression],
rightKeys: Seq[Expression],
joinType: JoinType,
buildSide: BuildSide): SparkPlan
buildSide: BuildSide,
isSkewJoin: Boolean): SparkPlan

def createNativeExpandExec(
projections: Seq[Seq[Expression]],
Expand Down
Loading