[SPARK-35282][SQL][FOLLOWUP] Simplify condition code of shuffled hash join
### What changes were proposed in this pull request? Simplify the condition code which is introduced by [SPARK-35282](https://issues.apache.org/jira/browse/SPARK-35282). ### Why are the changes needed? Reduce the code size and make code more readable. ### Does this PR introduce _any_ user-facing change? No ### How was this patch tested? Pass CI Closes #33046 from ulysses-you/simplify-shj. Authored-by: ulysses-you <ulyssesyou18@gmail.com> Signed-off-by: Wenchen Fan <wenchen@databricks.com>
This commit is contained in:
parent
5e77ca8071
commit
ff9ba89dcb
|
@ -272,28 +272,16 @@ trait JoinSelectionHelper {
|
||||||
val buildLeft = if (hintOnly) {
|
val buildLeft = if (hintOnly) {
|
||||||
hintToShuffleHashJoinLeft(hint)
|
hintToShuffleHashJoinLeft(hint)
|
||||||
} else {
|
} else {
|
||||||
if (hintToPreferShuffleHashJoinLeft(hint)) {
|
hintToPreferShuffleHashJoinLeft(hint) ||
|
||||||
true
|
(!conf.preferSortMergeJoin && canBuildLocalHashMapBySize(left, conf) &&
|
||||||
} else {
|
muchSmaller(left, right))
|
||||||
if (!conf.preferSortMergeJoin) {
|
|
||||||
canBuildLocalHashMapBySize(left, conf) && muchSmaller(left, right)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
val buildRight = if (hintOnly) {
|
val buildRight = if (hintOnly) {
|
||||||
hintToShuffleHashJoinRight(hint)
|
hintToShuffleHashJoinRight(hint)
|
||||||
} else {
|
} else {
|
||||||
if (hintToPreferShuffleHashJoinRight(hint)) {
|
hintToPreferShuffleHashJoinRight(hint) ||
|
||||||
true
|
(!conf.preferSortMergeJoin && canBuildLocalHashMapBySize(right, conf) &&
|
||||||
} else {
|
muchSmaller(right, left))
|
||||||
if (!conf.preferSortMergeJoin) {
|
|
||||||
canBuildLocalHashMapBySize(right, conf) && muchSmaller(right, left)
|
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
getBuildSide(
|
getBuildSide(
|
||||||
canBuildShuffledHashJoinLeft(joinType) && buildLeft,
|
canBuildShuffledHashJoinLeft(joinType) && buildLeft,
|
||||||
|
|
|
@ -45,11 +45,8 @@ object DynamicJoinSelection extends Rule[LogicalPlan] {
|
||||||
val maxShuffledHashJoinLocalMapThreshold =
|
val maxShuffledHashJoinLocalMapThreshold =
|
||||||
conf.getConf(SQLConf.ADAPTIVE_MAX_SHUFFLE_HASH_JOIN_LOCAL_MAP_THRESHOLD)
|
conf.getConf(SQLConf.ADAPTIVE_MAX_SHUFFLE_HASH_JOIN_LOCAL_MAP_THRESHOLD)
|
||||||
val advisoryPartitionSize = conf.getConf(SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES)
|
val advisoryPartitionSize = conf.getConf(SQLConf.ADVISORY_PARTITION_SIZE_IN_BYTES)
|
||||||
if (advisoryPartitionSize <= maxShuffledHashJoinLocalMapThreshold) {
|
advisoryPartitionSize <= maxShuffledHashJoinLocalMapThreshold &&
|
||||||
mapStats.bytesByPartitionId.forall(_ <= maxShuffledHashJoinLocalMapThreshold)
|
mapStats.bytesByPartitionId.forall(_ <= maxShuffledHashJoinLocalMapThreshold)
|
||||||
} else {
|
|
||||||
false
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private def selectJoinStrategy(plan: LogicalPlan): Option[JoinStrategyHint] = plan match {
|
private def selectJoinStrategy(plan: LogicalPlan): Option[JoinStrategyHint] = plan match {
|
||||||
|
|
Loading…
Reference in a new issue