You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2019/03/11 05:54:11 UTC

[GitHub] [spark] dongjoon-hyun opened a new pull request #24049: [SPARK-27123][SQL] Improve CollapseProject to handle projects cross limit/repartition/sample

dongjoon-hyun opened a new pull request #24049: [SPARK-27123][SQL] Improve CollapseProject to handle projects cross limit/repartition/sample
URL: https://github.com/apache/spark/pull/24049
 
 
   ## What changes were proposed in this pull request?
   
   `CollapseProject` optimizer simplifies the plan by merging the adjacent projects and performing alias substitution.
   ```scala
   scala> sql("SELECT b c FROM (SELECT a b FROM t)").explain
   == Physical Plan ==
   *(1) Project [a#5 AS c#1]
   +- Scan hive default.t [a#5], HiveTableRelation `default`.`t`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [a#5]
   ```
   
   We can do that more complex cases like the following.
   
   **BEFORE**
   ```scala
   scala> sql("SELECT b c FROM (SELECT /*+ REPARTITION(1) */ a b FROM t)").explain
   == Physical Plan ==
   *(2) Project [b#0 AS c#1]
   +- Exchange RoundRobinPartitioning(1)
      +- *(1) Project [a#5 AS b#0]
         +- Scan hive default.t [a#5], HiveTableRelation `default`.`t`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [a#5]
   ```
   
   **AFTER**
   ```scala
   scala> sql("SELECT b c FROM (SELECT /*+ REPARTITION(1) */ a b FROM t)").explain
   == Physical Plan ==
   Exchange RoundRobinPartitioning(1)
   +- *(1) Project [a#11 AS c#7]
      +- Scan hive default.t [a#11], HiveTableRelation `default`.`t`, org.apache.hadoop.hive.serde2.lazy.LazySimpleSerDe, [a#11]
   ```
   
   ## How was this patch tested?
   
   Pass the Jenkins with the newly added and updated test cases.

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


With regards,
Apache Git Services

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