You can’t get the alias. In RelNode-land there is no such concept. Just the 
inputs to the current RelNode, identified by ordinal.

Maybe at the time of SQL-to-RelNode conversion you can convert the aliases in 
the hint into ordinals. That’s the last moment that aliases are available.  

Julian

> On Aug 16, 2023, at 7:51 PM, LakeShen <[email protected]> wrote:
> 
> Hi Community,
> 
> Currently I'm working on Calcite SQL Hint,and I want to know how to get the
> table alias in al RelNode tree.
> 
> For example,consider the following sql :
> 
> select /*+ BROADCAST(a,b) */ * from nation as a left join nation as b on
> a.N_REGIONKEY = b.N_REGIONKEY
> 
> The hint BROADCAST(a,b) indicates that the Shuffle type of Join uses
> BROADCAST,a is left table alias,b is right table alias.
> 
> SQL corresponding to RelNode Tree is :
> 
> LogicalProject(N_NATIONKEY=[$0], N_NAME=[$1], N_REGIONKEY=[$2],
> N_COMMENT=[$3], N_NATIONKEY0=[$4], N_NAME0=[$5], N_REGIONKEY0=[$6],
> N_COMMENT0=[$7]) LogicalJoin(condition=[=($2, $6)], joinType=[left])
> LogicalTableScan(table=[[tpch, NATION]]) LogicalTableScan(table=[[tpch,
> NATION]])
> 
> I want to know what table is alias a and what table is alias b,but I can't
> get the table for the aliases a and b in above RelNode tree.
> 
> In SqlToRelConverter#convertFrom method,it does not consider the alias
> information of the table.
> 
> Best,
> LakeShen

Reply via email to