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

Optimization of COUNT (1) in OVER window

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      When we parse a SQL:

      select COUNT(1) from T tumble(rowtime, interval 2 seconds)
      

      In RexBuild.addAggCall will do the optimize as follows:

      if(aggCall.getAggregation() instanceof SqlCountAggFunction && !aggCall.isDistinct()) {
          List rex = aggCall.getArgList();
          List index = nullableArgs(rex, aggArgTypes);
          if(!index.equals(rex)) {
              aggCall = aggCall.copy(index, aggCall.filterArg);
          }
      }
      

      After the code logic above, the COUNT(1) -> COUNT().

      But when we parser a SQL:

      select COUNT(1) OVER(...) from T.
      

      we do not do the optimized the parameter. So in this JIRA. want add optimize for OVER constant parameter.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                julianhyde Julian Hyde
                Reporter:
                sunjincheng121 sunjincheng
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated: