There is a class RelRoot that wraps the top-most RelNode, and projects away 
columns that are only used for sorting. Read through 
https://issues.apache.org/jira/browse/CALCITE-2999 
<https://issues.apache.org/jira/browse/CALCITE-2999>, where someone had the 
same misunderstanding that you have.


> On Mar 4, 2020, at 3:43 AM, JiaTao Tao <[email protected]> wrote:
> 
> SQL;
> ```
> SELECT u.ID, u.NAME
> FROM USERS u
> ORDER BY u.AGE
> ```
> 
> PLAN:
> ```
> LogicalSort(sort0=[$2], dir0=[ASC])
>  LogicalProject(ID=[$0], NAME=[$1], AGE=[$2])
>    EnumerableTableScan(table=[[RECR, USERS]])
> ```
> Plan's row type: RecordType(INTEGER ID, VARCHAR NAME, INTEGER AGE)
> 
> But the SQL only project ID and NAME, there should be a LogicalProject
> (ID, NAME) on LogicalSort. Is this by design? And what about this extra
> column?
> 
> 
> 
> Regards!
> 
> Aron Tao

Reply via email to