xianyinxin 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_r308072946
 
 

 ##########
 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:
   Fixed.

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to