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

    https://github.com/apache/spark/pull/14452#discussion_r78494742
  
    --- Diff: 
sql/core/src/main/scala/org/apache/spark/sql/execution/exchange/EnsureRequirements.scala
 ---
    @@ -268,3 +269,35 @@ case class EnsureRequirements(conf: SQLConf) extends 
Rule[SparkPlan] {
         case operator: SparkPlan => ensureDistributionAndOrdering(operator)
       }
     }
    +
    +
    +/**
    + * Pushs down [[ShuffleExchange]] on the top of [[CommonSubqueryExec]] to 
make them reusable.
    + */
    +case object PushDownShuffleExchange extends Rule[SparkPlan] {
    --- End diff --
    
    The common pattern of common subquery in TPC-DS, is joining two or more the 
same subquery. The joining is `SortMergeJoin` and `ShuffleExchange` is executed 
for all the subqueries after some operators (e.g., `Project`, `Filter`).
    
    E.g.,
    
          :     :- *SortMergeJoin [customer_id#898], [customer_id#912], Inner
          :     :  :- *Sort [customer_id#898 ASC], false, 0
          :     :  :  +- Exchange hashpartitioning(customer_id#898, 200)
          :     :  :     +- *Project [customer_id#898, year_total#902]
          :     :  :        +- *Filter (((((isnotnull(year#901) && 
isnotnull(year_total#902)) && (sale_type#903 = s)) && (year#901 = 2001)) && 
(year_total#902 > 0.0)) && isnotnull(customer_id#898))
          :     :  :           +- CommonSubquery [customer_id#898, 
customer_first_name#899, customer_last_name#900, year#901, year_total#902, 
sale_type#903]
    
    This rule is to pushdown `ShuffleExchange` on the top of 
`CommonSubqueryExec`. So other `ShuffleExchange`s can be transformed to 
`ReusedExchange` later. Then we can reuse the exchange.



---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to