cloud-fan commented on a change in pull request #23036: [SPARK-26065][SQL]
Change query hint from a `LogicalPlan` to a field
URL: https://github.com/apache/spark/pull/23036#discussion_r245623683
##########
File path:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
##########
@@ -40,24 +74,30 @@ object CostBasedJoinReorder extends Rule[LogicalPlan] with
PredicateHelper {
if (!conf.cboEnabled || !conf.joinReorderEnabled) {
plan
} else {
+ // Use a map to track the hints on the join items.
+ val hintMap = new mutable.HashMap[AttributeSet, HintInfo]
val result = plan transformDown {
// Start reordering with a joinable item, which is an InnerLike join
with conditions.
- case j @ Join(_, _, _: InnerLike, Some(cond)) =>
- reorder(j, j.output)
- case p @ Project(projectList, Join(_, _, _: InnerLike, Some(cond)))
+ case j @ Join(_, _, _: InnerLike, Some(cond), _) =>
+ reorder(j, j.output, hintMap)
+ case p @ Project(projectList, Join(_, _, _: InnerLike, Some(cond), _))
if projectList.forall(_.isInstanceOf[Attribute]) =>
- reorder(p, p.output)
+ reorder(p, p.output, hintMap)
}
-
- // After reordering is finished, convert OrderedJoin back to Join
- result transformDown {
- case OrderedJoin(left, right, jt, cond) => Join(left, right, jt, cond)
+ // After reordering is finished, convert OrderedJoin back to Join.
+ result transform {
+ case OrderedJoin(left, right, jt, cond) =>
+ Join(left, right, jt, cond,
+ JoinHint(hintMap.get(left.outputSet),
hintMap.get(right.outputSet)))
Review comment:
nit:
```
val joinHint = JoinHint(hintMap.get(left.outputSet),
hintMap.get(right.outputSet))
Join(left, right, jt, cond, joinHint)
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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]