You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@calcite.apache.org by "Julian Hyde (Jira)" <ji...@apache.org> on 2021/02/28 00:26:00 UTC

[jira] [Commented] (CALCITE-4497) In RelBuilder, support windowed aggregate functions (OVER)

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

Julian Hyde commented on CALCITE-4497:
--------------------------------------

Just about complete: [julianhyde//4497-over|https://github.com/julianhyde/calcite/tree/4497-over]; comments welcome.

> In RelBuilder, support windowed aggregate functions (OVER)
> ----------------------------------------------------------
>
>                 Key: CALCITE-4497
>                 URL: https://issues.apache.org/jira/browse/CALCITE-4497
>             Project: Calcite
>          Issue Type: Bug
>            Reporter: Julian Hyde
>            Assignee: Julian Hyde
>            Priority: Major
>
> In {{RelBuilder}}, support windowed aggregate functions (OVER). Currently, you have to write code like this (from [testAggregatedWindowFunction|https://github.com/apache/calcite/blob/f1da65504e598928cf77aa6a7244552692ae2529/core/src/test/java/org/apache/calcite/rel/rel2sql/RelToSqlConverterTest.java#L830]):
> {code}
> b.scan("EMP")
>         .project(b.field("SAL"))
>         .project(
>             b.alias(
>                 b.getRexBuilder().makeOver(
>                     b.getTypeFactory().createSqlType(SqlTypeName.INTEGER),
>                     SqlStdOperatorTable.RANK, ImmutableList.of(),
>                     ImmutableList.of(),
>                     ImmutableList.of(
>                         new RexFieldCollation(b.field("SAL"),
>                             ImmutableSet.of())),
>                     RexWindowBounds.UNBOUNDED_PRECEDING,
>                     RexWindowBounds.UNBOUNDED_FOLLOWING,
>                     true, true, false, false, false),
>                 "rank"))
> {code}
> but potentially you could write this:
> {code}
> b.scan("EMP")
>         .project(b.field("SAL"))
>         .project(
>             b.aggregateCall(SqlStdOperatorTable.RANK)
>                 .over()
>                 .rowsUnbounded()
>                 .sort(b.field("SAL))
>                 .as("rank"))
> {code}
> {{class RelBuilder}} would need a new inner {{interface OverCall}}, and {{class RelBuilder.AggCall}} would need a new method {{OverCall over()}}.



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