Skip to content

Commit

Permalink
address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
maryannxue committed Jan 7, 2019
1 parent 17b7cce commit 97377dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,8 @@ object CostBasedJoinReorder extends Rule[LogicalPlan] with PredicateHelper {
// 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)))
val joinHint = JoinHint(hintMap.get(left.outputSet), hintMap.get(right.outputSet))
Join(left, right, jt, cond, joinHint)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,12 @@ object ReorderJoin extends Rule[LogicalPlan] with PredicateHelper {
*
* @param input a list of LogicalPlans to inner join and the type of inner join.
* @param conditions a list of condition for join.
* @param leftPlans a list of LogicalPlans contained in the left join child.
* @param hintMap a map of relations to their corresponding hints.
* @param hintMap a map of relation output attribute sets to their corresponding hints.
*/
@tailrec
final def createOrderedJoin(
input: Seq[(LogicalPlan, InnerLike)],
conditions: Seq[Expression],
leftPlans: Seq[LogicalPlan],
hintMap: Map[AttributeSet, HintInfo]): LogicalPlan = {
assert(input.size >= 2)
if (input.size == 2) {
Expand Down Expand Up @@ -88,8 +86,7 @@ object ReorderJoin extends Rule[LogicalPlan] with PredicateHelper {
JoinHint(hintMap.get(left.outputSet), hintMap.get(right.outputSet)))

// should not have reference to same logical plan
createOrderedJoin(Seq((joined, Inner)) ++ rest.filterNot(_._1 eq right),
others, leftPlans :+ right, hintMap)
createOrderedJoin(Seq((joined, Inner)) ++ rest.filterNot(_._1 eq right), others, hintMap)
}
}

Expand All @@ -100,12 +97,12 @@ object ReorderJoin extends Rule[LogicalPlan] with PredicateHelper {
val starJoinPlan = StarSchemaDetection.reorderStarJoins(input, conditions)
if (starJoinPlan.nonEmpty) {
val rest = input.filterNot(starJoinPlan.contains(_))
createOrderedJoin(starJoinPlan ++ rest, conditions, Seq(starJoinPlan.head._1), hintMap)
createOrderedJoin(starJoinPlan ++ rest, conditions, hintMap)
} else {
createOrderedJoin(input, conditions, Seq(input.head._1), hintMap)
createOrderedJoin(input, conditions, hintMap)
}
} else {
createOrderedJoin(input, conditions, Seq(input.head._1), hintMap)
createOrderedJoin(input, conditions, hintMap)
}

if (p.sameOutput(reordered)) {
Expand Down

0 comments on commit 97377dd

Please sign in to comment.