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/12 00:34:00 UTC
[jira] [Created] (CALCITE-4497) In RelBuilder, support windowed
aggregate functions (OVER)
Julian Hyde created CALCITE-4497:
------------------------------------
Summary: 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
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)