[ 
https://issues.apache.org/jira/browse/CALCITE-5144?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17533959#comment-17533959
 ] 

Julian Hyde commented on CALCITE-5144:
--------------------------------------

I don’t think this is a bug. The {{RelNode}} representation doesn’t contain 
names and that is what makes it powerful and flexible. Therefore 
{{SqlToRelConverter}} should not attempt to preserve names.

You seem to suggest that this is a problem for hints. Then it’s something that 
the hints system needs to deal with. Perhaps switch to position-based hints 
during sql-to-rel.

Attaching names as annotations/hints seems to be the wrong direction to go, 
because it will be brittle and will create two different code paths - one for 
{{RelNode}} instances that came from SQL via {{SqlToRelConverter}} and a 
different one for {{RelNode}} instances that were created manually.

> table alias is lost by SqlToRelConverter
> ----------------------------------------
>
>                 Key: CALCITE-5144
>                 URL: https://issues.apache.org/jira/browse/CALCITE-5144
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: xuyang
>            Priority: Major
>
> I found that in SqlToRelConverter#convertFrom, "AS" only cares about the 
> first operand and just ignore the second operand, and this behavior will 
> cause the information of the table alias lost.
> The simple SQL is :
> {code:java}
> // code placeholder
> select * from (select * from emp) t1 {code}
> The "t1" will be lost in the final RelNode tree. I think we can retain this 
> alias information in the RelNode by some way.
> The real scenarios that require table aliases are Join Hint on subquery just 
> like:
> {code:java}
> // code placeholder
> SELECT /*+ USE_NL(v2) */ v2.a
> FROM (select * from test1) v2 join test2 ON v2.a = test2.a {code}



--
This message was sent by Atlassian Jira
(v8.20.7#820007)

Reply via email to