public AggregateAnalysisResult analyze(
      final ImmutableAnalysis analysis,
      final List<SelectExpression> finalProjection
  ) {
    if (!analysis.getGroupBy().isPresent()) {
      throw new IllegalArgumentException("Not an aggregate query");
    }

    final AggAnalyzer aggAnalyzer = new AggAnalyzer(analysis, functionRegistry);
    aggAnalyzer.process(finalProjection);
    return aggAnalyzer.result();
  }
@Test
  public void shouldNotCaptureWindowEndAsRequiredColumn() {
    // Given:
    givenWindowExpression();
    givenSelectExpression(new UnqualifiedColumnReferenceExp(SystemColumns.WINDOWEND_NAME));

    // When:
    final AggregateAnalysisResult result = analyzer.analyze(analysis, selects);

    // Then:
    final List<ColumnName> requiredColumnNames = result.getRequiredColumns().stream()
        .map(ColumnReferenceExp::getColumnName)
        .collect(Collectors.toList());

    assertThat(requiredColumnNames, not(hasItem(SystemColumns.WINDOWEND_NAME)));
  }