[
https://issues.apache.org/jira/browse/CALCITE-1551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15770717#comment-15770717
]
Jess Balint commented on CALCITE-1551:
--------------------------------------
you said:
bq. at point 2 and point 3 there are two tables \[e, d]
There's a difference between these two points. At point 2, there are two frames
on the stack. Each frame has only one alias in the list. At point 3, there is
one stack frame with two aliases (and row types) in the list.
With the relational algebra, we don't consider tables "in scope", but instead
we consider each expression to be a relation itself. The current approach
accumulates aliases and it works for joins _until there is a projection_
because the set of fields can be decomposed into sequential disjoint lists -
represented by the list of pairs. Howver, this artificially limits the
propagation of aliases when the sequential lists are no longer maintained, e.g.
a projection with arbitrary ordering of fields from both tables in the join.
Unless I'm wrong, the projection needs to maintain a list of pairs in
{{Frame.right}} whereby the (concatenated list of) row types fields correspond
exactly with the projected elements. You suggested:
bq. that project should create two NEW aliases d and e with row-types that are
subsets of the original d and e row types
Applying this to the example, we would need two pairs for {{e}} as projection's
use of {{e}}'s fields is not sequential. Two aliases are not enough. This would
require something like this at point 4:
{{\[<e, RecordType(ENAME VARCHAR)>, <d, RecordType(DNAME VARCHAR)>, <e,
RecordType(MGR INTEGER)>, <null, RecordType($f2 INTEGER)>]}}
The change I am proposing is not too dissimilar but treats each stack frame as
one relation (not a sequence of aliased relations) with a single list of
fields. Each field includes the relation alias from where it originated.
Thanks.
> RelBuilder's project() doesn't preserve alias
> ---------------------------------------------
>
> Key: CALCITE-1551
> URL: https://issues.apache.org/jira/browse/CALCITE-1551
> Project: Calcite
> Issue Type: Bug
> Components: core
> Reporter: Jess Balint
> Assignee: Julian Hyde
> Priority: Minor
>
> The alias should be preserved by the project node, e.g.
> {code:java}
> .scan("EMP")
> .as("EMP_alias")
> .project(...) // resets alias to null
> .project(builder.field("EMP_alias", "DEPTNO")) // fails that no such alias
> exists
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)