Github user maryannxue commented on a diff in the pull request:
https://github.com/apache/spark/pull/20345#discussion_r198206001
--- Diff:
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/joins.scala
---
@@ -84,19 +84,50 @@ object ReorderJoin extends Rule[LogicalPlan] with
PredicateHelper {
}
}
+ // Extract a list of logical plans to be joined for join-order
comparisons.
+ // Since `ExtractFiltersAndInnerJoins` handles left-deep trees only,
this function have
+ // the same strategy to extract the plan list.
+ private[optimizer] def extractLeftDeepInnerJoins(plan: LogicalPlan)
+ : Seq[LogicalPlan] = plan match {
+ case j @ Join(left, right, _: InnerLike, _) => right +:
extractLeftDeepInnerJoins(left)
+ case p @ Project(_, j @ Join(_, _, _: InnerLike, _)) =>
extractLeftDeepInnerJoins(j)
+ case _ => Seq(plan)
+ }
+
+ private def sameJoinOrder(plan1: LogicalPlan, plan2: LogicalPlan):
Boolean = {
+ extractLeftDeepInnerJoins(plan1) == extractLeftDeepInnerJoins(plan2)
+ }
+
+ private def mayCreateOrderedJoin(
--- End diff --
Sorry, I didn't make myself very clear. I was suggesting something like
"projectIfNecessary(joinReorderedPlan: LogicalPlan, originalPlan: LogicalPlan)"
Please also refer to the comment below.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]