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

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 1.27.0
    • None
    • 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

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            julianhyde Julian Hyde
            julianhyde Julian Hyde
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment