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

Julian Hyde commented on CALCITE-2649:
--------------------------------------

The following is why {{RelBuilder#field(inputCount,alias,fieldName)}} exists. 
Suppose I have pushed EMP and DEPT onto the stack, now I want to form the 
condition DEPT.DEPTNO = 10. If that condition is going to be in a Filter, then 
I will need a RexInputRef with index 0, before DEPTNO is the first field of 
DEPT. But if that condition is going to be the ON clause of a join then I need 
a RexInputRef with index 6, because fields 0 - 5 are the fields of EMP. So, 
when building the field references I need to know how many RelNodes I am just 
about to pop off the stack. Therefore I pass inputCount = 2 if I am just about 
to make a Join, and inputCount = 1 if I am just about to make a Filter.

I'm guessing you'd like a higher level API that keeps track of that stuff. If 
so, I'd say go ahead and build that API as a wrapper around RelBuilder. 
RelBuilder does some lightweight tracking of field names and table aliases 
(e.g. using Frames) but in my opinion if it got seriously into the business of 
tracking namespaces then it would probably stretch its design too far.

If you understand RexRangeRef and can come up with a cogent proposal using 
those I would consider it.

> Allow RelBuilder to create field references to aliased relations without 
> knowing the size of the stack
> ------------------------------------------------------------------------------------------------------
>
>                 Key: CALCITE-2649
>                 URL: https://issues.apache.org/jira/browse/CALCITE-2649
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>    Affects Versions: 1.17.0
>            Reporter: Stamatis Zampetakis
>            Assignee: Julian Hyde
>            Priority: Minor
>              Labels: beginner, newbie
>             Fix For: 1.18.0
>
>
> As of [CALCITE-1523|https://issues.apache.org/jira/browse/CALCITE-1523] it is 
> possible to create field references to aliased relations anywhere in the 
> stack. However the respective field method requires to pass as a parameter 
> the inputCount (i.e., size of the stack). This is not very convenient since 
> clients of RelBuilder are obliged to track the size of the stack (leading to 
> the uneseccary creation of Wrapper classes).



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to