GitHub user gatorsmile opened a pull request:

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

    [SPARK-16594] [SQL] Remove Physical Plan Differences when Table Scan Having 
Duplicate Columns

    #### What changes were proposed in this pull request?
    Currently, we keep two implementations for planning scans over data 
sources. There is one difference between two implementation when deciding 
whether a `Project` is needed or not. 
    
    - Data Source Table Scan: 
https://github.com/apache/spark/blob/b1e5281c5cb429e338c3719c13c0b93078d7312a/sql/core/src/main/scala/org/apache/spark/sql/execution/datasources/DataSourceStrategy.scala#L322-L395
    
      - `SELECT b, b FROM oneToTenPruned`: **_Add `ProjectExec`._**
    
    - Hive Table Scan and In-memory Table Scan:
    
https://github.com/apache/spark/blob/865ec32dd997e63aea01a871d1c7b4947f43c111/sql/core/src/main/scala/org/apache/spark/sql/execution/SparkPlanner.scala#L71-L99
 
    
      - `SELECT b, b FROM oneToTenPruned`: **_No `ProjectExec` is added._** 
    
    **Note.** When alias is being used, we will always add `ProjectExec` in all 
the scan types.
    
      - `SELECT b as alias_b, b FROM oneToTenPruned`: **_Add `ProjectExec`._**
    
    Because selecting the same column twice without adding `alias` is very 
weird, no clue why the code needs to behave differently here. This PR is to 
remove the differences. 
    
    #### How was this patch tested?
    Updated/added a test case

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

    $ git pull https://github.com/gatorsmile/spark removeProject

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

    https://github.com/apache/spark/pull/14240.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 #14240
    
----
commit ba7dcff8829c379666c417b87fc1e5022ed93141
Author: gatorsmile <[email protected]>
Date:   2016-07-17T07:26:47Z

    fix

----


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