I like it. I suppose that RelBuilder.join would continue to return RelBuilder, but “on” would be allowed only if the previous call was to “join”.
A “using” method should probably be added for completeness. And the field(int, int) and field(int, String) methods can be deprecated. Can you log a JIRA case please. Julian > On Oct 11, 2017, at 7:17 AM, Marc Prud'hommeaux <[email protected]> wrote: > > Julian- > > Is the only scenario in which the stack depth needs to be specified when you > are preforming a join? If so, perhaps the RelBuildr API could be simplified > so that rather than having to do: > > builder.scan("EMP").as("e").scan("DEPT").join(JoinRelType.LEFT, > builder.equals(builder.field(2, "e", "DEPTNO"), builder.field(2, "DEPT", > "DEPTNO"))) > > One could instead specify an “on” condition for the join after the join has > been made (and thus after the stack has been flattened): > > > builder.scan("EMP").as("e").scan("DEPT").join(JoinRelType.LEFT).on(builder.equals(builder.field("e", > "DEPTNO"), builder.field("DEPT", "DEPTNO"))) > > This would be similar to the filter example from > RelBuilderTest.testAliasPastTop(): > > > builder.scan("EMP").as("e").scan("DEPT").join(JoinRelType.LEFT).filter(builder.equals(builder.field("e", > "DEPTNO"), builder.field("DEPT", "DEPTNO"))) > > -Marc > > >> On Oct 6, 2017, at 4:39 PM, Julian Hyde <[email protected]> wrote: >> >> When forming a reference it needs to know how many inputs you are >> going to pop off the stack in your next operation. Most operations pop >> 1, but join pops 2. Set operations may pop more, but they don't use >> expressions, so it's moot. >> >> You don't necessarily pop the whole stack. For instance, if you're >> forming a right-deep join (a join (b join c)) for instance. You would >> have a, b, c on the stack and just pop (b, c) to make the first join. >> >> So, I can't see a way to remove the inputCount parameter. >> >> On Fri, Oct 6, 2017 at 12:33 PM, Marc Prud'hommeaux <[email protected]> wrote: >>> >>> Using the RelBuilder API, I’d like to get a field by alias & name without >>> having to keep track of the inputCount. I’ve found that the following >>> always seems to work fine (after making stack a public variable): >>> >>> builder.field(builder.stack.count(), “MYALIAS”, “myfield”) >>> >>> My question: why does RelBuilder.field(String, String) use an inputCount of >>> 1 instead of the size of the stack? Doing so would allow people to search >>> for field names without having to keep track of the number of inputs. >>> >>> I understand why accessing fields by index require the inputCount and >>> inputOrdinal, but searching for fields by name could just scan the entire >>> stack and return the first matching field name + alias. >>> >>> >
