GitHub user scwf opened a pull request:

    https://github.com/apache/spark/pull/5838

    [SPARK-7303] [SQL] push down project if possible when the child is sort

    Optimize the case of `project(_, sort)` , a example is:
    
    `select key from (select * from testData order by key) t`
    
    before this PR:
    ```
    == Parsed Logical Plan ==
    'Project ['key]
     'Subquery t
      'Sort ['key ASC], true
       'Project [*]
        'UnresolvedRelation [testData], None
    
    == Analyzed Logical Plan ==
    Project [key#0]
     Subquery t
      Sort [key#0 ASC], true
       Project [key#0,value#1]
        Subquery testData
         LogicalRDD [key#0,value#1], MapPartitionsRDD[1]
    
    == Optimized Logical Plan ==
    Project [key#0]
     Sort [key#0 ASC], true
      LogicalRDD [key#0,value#1], MapPartitionsRDD[1] 
    
    == Physical Plan ==
    Project [key#0]
     Sort [key#0 ASC], true
      Exchange (RangePartitioning [key#0 ASC], 5), []
       PhysicalRDD [key#0,value#1], MapPartitionsRDD[1] 
    ```
    
    after this PR 
    ```
    == Parsed Logical Plan ==
    'Project ['key]
     'Subquery t
      'Sort ['key ASC], true
       'Project [*]
        'UnresolvedRelation [testData], None
    
    == Analyzed Logical Plan ==
    Project [key#0]
     Subquery t
      Sort [key#0 ASC], true
       Project [key#0,value#1]
        Subquery testData
         LogicalRDD [key#0,value#1], MapPartitionsRDD[1] 
    
    == Optimized Logical Plan ==
    Sort [key#0 ASC], true
     Project [key#0]
      LogicalRDD [key#0,value#1], MapPartitionsRDD[1] 
    
    == Physical Plan ==
    Sort [key#0 ASC], true
     Exchange (RangePartitioning [key#0 ASC], 5), []
      Project [key#0]
       PhysicalRDD [key#0,value#1], MapPartitionsRDD[1] 
    ```
    
    this rule will first do column pruning on the table and then do sorting.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/scwf/spark pruning

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/5838.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #5838
    
----
commit b09b89571a75e5dafb6765845c0ba370029d7406
Author: scwf <[email protected]>
Date:   2015-05-01T14:22:35Z

    improve column pruning

----


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