maropu commented on a change in pull request #24164: [SPARK-27225][SQL]
Implement join strategy hints
URL: https://github.com/apache/spark/pull/24164#discussion_r268014746
##########
File path:
sql/core/src/main/scala/org/apache/spark/sql/execution/SparkStrategies.scala
##########
@@ -239,18 +275,47 @@ abstract class SparkStrategies extends
QueryPlanner[SparkPlan] {
def apply(plan: LogicalPlan): Seq[SparkPlan] = plan match {
- // --- BroadcastHashJoin
--------------------------------------------------------------------
+ // --- Hints specified, choose join strategy based on hints.
--------------------------------
- // broadcast hints were specified
+ // broadcast hints specified with equi-join keys, use broadcast-hash
case ExtractEquiJoinKeys(joinType, leftKeys, rightKeys, condition, left,
right, hint)
- if canBroadcastByHints(joinType, left, right, hint) =>
+ if canBroadcastByHints(joinType, left, right, hint) =>
val buildSide = broadcastSideByHints(joinType, left, right, hint)
Seq(joins.BroadcastHashJoinExec(
leftKeys, rightKeys, joinType, buildSide, condition,
planLater(left), planLater(right)))
- // broadcast hints were not specified, so need to infer it from size and
configuration.
+ // broadcast hints specified with no equi-join keys, use
broadcast-nested-loop
+ case j @ logical.Join(left, right, joinType, condition, hint)
+ if canBroadcastByHints(joinType, left, right, hint) =>
+ val buildSide = broadcastSideByHints(joinType, left, right, hint)
+ Seq(joins.BroadcastNestedLoopJoinExec(
+ planLater(left), planLater(right), buildSide, joinType, condition))
+
+ // shuffle-merge hints specified
+ case ExtractEquiJoinKeys(joinType, leftKeys, rightKeys, condition, left,
right, hint)
+ if canShuffleMergeByHints(leftKeys, hint) =>
+ Seq(joins.SortMergeJoinExec(
+ leftKeys, rightKeys, joinType, condition, planLater(left),
planLater(right)))
+
+ // shuffle-hash hints specified
+ case ExtractEquiJoinKeys(joinType, leftKeys, rightKeys, condition, left,
right, hint)
+ if canShuffleHashByHints(joinType, left, right, hint) =>
+ val buildSide = shuffleHashSideByHints(joinType, left, right, hint)
+ Seq(joins.ShuffledHashJoinExec(
+ leftKeys, rightKeys, joinType, buildSide, condition,
planLater(left), planLater(right)))
+
+ // shuffle-replicate-nl hints specified
+ case logical.Join(left, right, _: InnerLike, condition, hint)
+ if shuffleReplicateNLByHints(hint) =>
+ Seq(joins.CartesianProductExec(planLater(left), planLater(right),
condition))
+
+
+ // --- No hints specified, choose join strategy based on size and
configuration. ------------
Review comment:
The `JoinSelection` class is getting large, so how about moving this class
into a separate one?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]