yeshengm commented on a change in pull request #24983: [SPARK-27714][SQL][CBO] 
Support Genetic Algorithm based join reorder
URL: https://github.com/apache/spark/pull/24983#discussion_r307919512
 
 

 ##########
 File path: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
 ##########
 @@ -59,11 +60,19 @@ object CostBasedJoinReorder extends Rule[LogicalPlan] with 
PredicateHelper {
   private def reorder(plan: LogicalPlan, output: Seq[Attribute]): LogicalPlan 
= {
     val (items, conditions) = extractInnerJoins(plan)
     val result =
-      // Do reordering if the number of items is appropriate and join 
conditions exist.
+      // Do reordering if the join conditions exist.
       // We also need to check if costs of all items can be evaluated.
-      if (items.size > 2 && items.size <= conf.joinReorderDPThreshold && 
conditions.nonEmpty &&
+      if (items.size > 2 && conditions.nonEmpty &&
           items.forall(_.stats.rowCount.isDefined)) {
-        JoinReorderDP.search(conf, items, conditions, output)
+        // Reorder with DP when the the number of items is appropriate,
+        // otherwise try GA if it is enabled.
+        if (items.size <= conf.joinReorderDPThreshold) {
+          JoinReorderDP.search(conf, items, conditions, output)
+        } else if (conf.joinReorderGAEnabled) {
+          JoinReorderGA.search(conf, items, conditions, output).getOrElse(plan)
+        } else {
+          plan
+        }
       } else {
         plan
       }
 
 Review comment:
   nit. Eliminate two `else` here and return `plan` at the end of this function.

----------------------------------------------------------------
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]

Reply via email to