Github user hvanhovell commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17240#discussion_r105368556
  
    --- Diff: 
sql/catalyst/src/main/scala/org/apache/spark/sql/catalyst/optimizer/CostBasedJoinReorder.scala
 ---
    @@ -122,46 +123,59 @@ case class CostBasedJoinReorder(conf: CatalystConf) 
extends Rule[LogicalPlan] wi
      * level 3: p({A, B, C, D})
      * where p({A, B, C, D}) is the final output plan.
      *
    - * For cost evaluation, since physical costs for operators are not 
available currently, we use
    - * cardinalities and sizes to compute costs.
    + * To evaluate cost for a given plan, we calculate the sum of 
cardinalities for all intermediate
    + * joins in the plan.
      */
     object JoinReorderDP extends PredicateHelper {
     
       def search(
           conf: CatalystConf,
           items: Seq[LogicalPlan],
    -      conditions: Set[Expression],
    -      topOutput: AttributeSet): Option[LogicalPlan] = {
    +      conditions: Set[Expression]): Option[LogicalPlan] = {
     
         // Level i maintains all found plans for i + 1 items.
         // Create the initial plans: each plan is a single item with zero cost.
    -    val itemIndex = items.zipWithIndex
    +    val itemIndex = items.zipWithIndex.map(e => (e._2, e._1)).toMap
    --- End diff --
    
    NIT: use swap: `items.zipWithIndex.map(_.swap).toMap`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to