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

Julian Hyde commented on CALCITE-3524:
--------------------------------------

I missed this case and PR the first time around. I'd like to revive it. (It 
came up when we were discussing CALCITE-4486, UNIQUE predicate.)

The PR looks like a good start. The basic tests are there. The design is right 
(leaning heavily on RexSubQuery). What's left:
* update [algebra 
reference|https://calcite.apache.org/docs/algebra.html#api-summary];
* expand the javadoc of each method, perhaps including an example;
* remove the {{SqlQuantifyOperator}} argument of {{some}}; let's have separate 
{{some}} and {{all}} methods;
* take a pass through {{SqlToRelConverter}} and {{RelOptRule}} instances and 
use this API where possible
* consider moving to a stack-based approach (see below).

A stack-based API would not pass a {{RelNode}} directly but instead pop the top 
{{RelNode}} off the stack. The above example would look like this:
{code:java}
    RelNode root = builder.scan("EMP")
        .scan("DEPT")
        .filter(
            builder.call(SqlStdOperatorTable.EQUALS,
                builder.field("DNAME"),
                builder.literal("AAA")))
        .project(builder.field("DEPTNO"))
        .filter(builder.inQuery(builder.field("DEPTNO")))
        .build();
{code}

The stack-based approach is more consistent with RelBuilder's ethos. Note that 
you'd only have to change one line of the example to use a semiJoin rather than 
"WHERE IN". That's a sign that the API is right.

(I renamed the {{in}} method to {{inQuery}} because, with the {{RelNode}} 
parameter gone, it would be easy to confuse with the existing {{in}} methods.)

[~agajst], I know this PR was a long time ago. Would you be interested in 
continuing to work on it? If so, promise I'll review it and get it into 1.28.

> Add methods to RelBuilder to create RexSubQuery
> -----------------------------------------------
>
>                 Key: CALCITE-3524
>                 URL: https://issues.apache.org/jira/browse/CALCITE-3524
>             Project: Calcite
>          Issue Type: Improvement
>          Components: core
>            Reporter: Amir Gajst
>            Assignee: Amir Gajst
>            Priority: Minor
>              Labels: pull-request-available
>          Time Spent: 3h 20m
>  Remaining Estimate: 0h
>
> When building relational expressions, the simplest way is by using the 
> RelBuilder which does not currently support creation of a RexSubQuery.
> We can add RexSubQuery creation functions to the RelBuilder to make it more 
> "visible" and convenient to use. 



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to