[
https://issues.apache.org/jira/browse/CALCITE-2654?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16674640#comment-16674640
]
Julian Hyde commented on CALCITE-2654:
--------------------------------------
{{RelBuilder.AggCall}} is not actually a {{RexNode}} (and nor are
{{AggregateCall}}, which are similar) because calls to aggregate functions
operate on sets of values, therefore they are not scalar expressions.
{{RelBuilder}} does create a few kinds of {{RexNode}}. Most methods are just
conveniences that could be done equally well by {{RexBuilder}}, but user code
is less verbose if {{RelBuilder}} does it, because the user may not have a
{{RexBuilder}} on hand. {{RelBuilder.field()}} and {.fields()}} do something
that {{RexBuilder}} could not do, because it knows the current {{RelNode}}
input and its field names.
> In RelBuilder, add a fluent API for building complex aggregate calls
> --------------------------------------------------------------------
>
> Key: CALCITE-2654
> URL: https://issues.apache.org/jira/browse/CALCITE-2654
> Project: Calcite
> Issue Type: Bug
> Reporter: Julian Hyde
> Assignee: Julian Hyde
> Priority: Major
>
> In RelBuilder, add a fluent API for building complex aggregate calls.
> Currently, the RelBuilder.aggregateCall has arguments aggFunction, distinct,
> approximate, filter, orderKeys,
> alias and operands, and in CALCITE-2224 we're adding orderKeys. You have to
> specify all of them, whether or not your function is DISTINCT or has a
> FILTER(WHERE) clause.
> The new API would be simple:
> * {{RelBuilder.aggregateCall(op, operands)}}
> * {{RelBuilder.sum(operand)}}
> * {{RelBuilder.count(operands)}}
> * {{RelBuilder.min(operands)}}
> and so forth. Each of these returns an AggCall, and we propose to add fluent
> methods to that:
> * {{AggCall.distinct(boolean)}}
> * {{AggCall.approximate(boolean)}}
> * {{AggCall.alias(String)}}
> * {{AggCall.filter(RexNode)}}
> * {{AggCall.sort(RexNode...)}} (for CALCITE-2224)
> Thus you can write
> {{builder.sum(builder.field("SAL)).distinct(true).alias("SUM_SAL")}}.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)