Uploaded image for project: 'Calcite'
  1. Calcite
  2. CALCITE-4497

In RelBuilder, support windowed aggregate functions (OVER)

VotersWatch issueWatchersLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.27.0
    • Component/s: None
    • Labels:
      None

      Description

      In RelBuilder, support windowed aggregate functions (OVER). Currently, you have to write code like this (from testAggregatedWindowFunction):

      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"))
      

      but potentially you could write this:

      b.scan("EMP")
              .project(b.field("SAL"))
              .project(
                  b.aggregateCall(SqlStdOperatorTable.RANK)
                      .over()
                      .rowsUnbounded()
                      .sort(b.field("SAL))
                      .as("rank"))
      

      class RelBuilder would need a new inner interface OverCall, and class RelBuilder.AggCall would need a new method OverCall over().

        Attachments

          Activity

            People

            • Assignee:
              julianhyde Julian Hyde
              Reporter:
              julianhyde Julian Hyde

              Dates

              • Created:
                Updated:
                Resolved:

                Issue deployment