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 shouldThrowOnNestedHavingAggFunctions() {
    // Given:
    final FunctionCall nestedCall = new FunctionCall(FunctionName.of("MIN"),
        ImmutableList.of(AGG_FUNCTION_CALL, COL2));

    givenHavingExpression(nestedCall);

    // When:
    final KsqlException e = assertThrows(KsqlException.class,
        () -> analyzer.analyze(analysis, selects));

    // Then:
    assertThat(e.getMessage(),
        containsString("Aggregate functions can not be nested: MIN(MAX())"));
  }