[
https://issues.apache.org/jira/browse/CALCITE-1551?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15774139#comment-15774139
]
Julian Hyde commented on CALCITE-1551:
--------------------------------------
I think you're proposing that each field has a two-part qualified name in
addition to its actual field name, and can be referenced by either. I think
that would be fine.
I believe you can apply multiple aliases, for example
{code}
builder.table("emp")
.as("e")
.project(...)
.as("e2")
.table("dept")
.as("d")
.join("deptno")
.as("ed")
.table("location")
.join("locid);
{code}
You can reference the "empno" field in 3 ways: "empno", ["e", "empno"], ["ed",
"empno"].
bq. With the relational algebra, we don't consider tables "in scope", but
instead we consider each expression to be a relation itself.
Yes, but we're augmenting relational algebra a bit. The output of the builder
is pure relational algebra. But the builder maintains some intermediate state
to make the process a bit easier. In particular, the "table alias" concept,
which is somewhat similar to table aliases in SQL, makes it easier to calculate
field offsets after joins have occurred. Your proposal achieves that, I think.
> 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)