Skip to content
This repository has been archived by the owner on Sep 18, 2023. It is now read-only.

Commit

Permalink
[NSE-529] Wrong build side may be chosen for SemiJoin when forcing us…
Browse files Browse the repository at this point in the history
…e of SHJ (#530)

Closes #529
  • Loading branch information
zhztheplayer authored Oct 18, 2021
1 parent 5b28dff commit c7c81be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@

package com.intel.oap.extension

import com.intel.oap.GazellePlugin
import com.intel.oap.GazellePluginConfig
import com.intel.oap.GazelleSparkExtensionsInjector

import org.apache.spark.sql.SparkSessionExtensions
import org.apache.spark.sql.Strategy
import org.apache.spark.sql.catalyst.SQLConfHelper
import org.apache.spark.sql.catalyst.optimizer.BuildLeft
import org.apache.spark.sql.catalyst.optimizer.BuildRight
import org.apache.spark.sql.catalyst.optimizer.JoinSelectionHelper
import org.apache.spark.sql.catalyst.planning.ExtractEquiJoinKeys
import org.apache.spark.sql.catalyst.plans.logical.LogicalPlan
Expand All @@ -42,7 +43,19 @@ object JoinSelectionOverrides extends Strategy with JoinSelectionHelper with SQL
if (GazellePluginConfig.getSessionConf.forceShuffledHashJoin) {
// Force use of ShuffledHashJoin in preference to SortMergeJoin. With no respect to
// conf setting "spark.sql.join.preferSortMergeJoin".
return Option(getSmallerSide(left, right)).map {
val leftBuildable = canBuildShuffledHashJoinLeft(joinType)
val rightBuildable = canBuildShuffledHashJoinRight(joinType)
if (!leftBuildable && !rightBuildable) {
return Nil
}
val buildSide = if (!leftBuildable) {
BuildRight
} else if (!rightBuildable) {
BuildLeft
} else {
getSmallerSide(left, right)
}
return Option(buildSide).map {
buildSide =>
Seq(joins.ShuffledHashJoinExec(
leftKeys,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,12 @@ class TPCDSSuite extends QueryTest with SharedSparkSession {
}
}

test("q95 - shj") {
withSQLConf(("spark.oap.sql.columnar.forceshuffledhashjoin", "true")) {
runner.runTPCQuery("q95", 1, true)
}
}

test("q47") {
runner.runTPCQuery("q47", 1, true)
}
Expand Down

0 comments on commit c7c81be

Please sign in to comment.