Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Incomplete
-
2.0.0
-
None
Description
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.