GitHub user dongjoon-hyun opened a pull request:

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

    [SPARK-14939][SQL] Eliminate No-op Alias SortOrder in Sort.

    ## What changes were proposed in this pull request?
    
    This issue aims to delete No-op **Alias** SortOrders in Sort. Currently, 
`EliminateSorts` removes direct foldable expressions, but cannot handle aliases.
    
    **Before**
    ```
    scala> sql("select a, year(current_date()) as y from (select 
explode(array(1,2)) a) order by y").explain()
    == Physical Plan ==
    WholeStageCodegen
    :  +- Sort [y#8 ASC], true, 0
    :     +- INPUT
    +- Exchange rangepartitioning(y#8 ASC, 200), None
       +- WholeStageCodegen
          :  +- Project [a#13,2016 AS y#8]
          :     +- INPUT
          +- Generate explode([1,2]), false, false, [a#13]
             +- Scan OneRowRelation[]
    ```
    
    **After**
    ```
    scala> sql("select a, year(current_date()) as y from (select 
explode(array(1,2)) a) order by y").explain()
    == Physical Plan ==
    WholeStageCodegen
    :  +- Project [a#13,2016 AS y#8]
    :     +- INPUT
    +- Generate explode([1,2]), false, false, [a#13]
       +- Scan OneRowRelation[]
    ```
    
    ## How was this patch tested?
    
    Pass the Jenkins tests including a new test case.

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

    $ git pull https://github.com/dongjoon-hyun/spark SPARK-14939

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

    https://github.com/apache/spark/pull/12719.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 #12719
    
----
commit 9b987848e399ea9c16da196ccdb91bde04066cf4
Author: Dongjoon Hyun <[email protected]>
Date:   2016-04-26T22:27:17Z

    [SPARK-XXX][SQL] Eliminate No-op Alias SortOrder in Sort.

----


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