@Override
  public String toString() {
    final StringWriter string = new StringWriter();
    final PrintWriter writer = new PrintWriter(string);

    final DebugExpressionVisitor<PrintWriter> visitor = new DebugExpressionVisitor<>(writer);
    writer.append("entity: ").append(entityClass().getName()).println();

    if (!projections().isEmpty()) {
      projections().forEach(p -> p.accept(visitor));
      writer.println();
    }

    filter().ifPresent(f -> {
      writer.append("filter: ");

      f.accept(visitor);
      writer.println();
    });

    if (!groupBy().isEmpty()) {
      writer.append("groupBy: ");
      groupBy().forEach(g -> g.accept(visitor));
      writer.println();
    }

    limit().ifPresent(limit -> writer.append(" limit:").append(String.valueOf(limit)).println());
    offset().ifPresent(offset -> writer.append(" offset:").append(String.valueOf(offset)).println());

    return string.toString();
  }
Check if current query has any aggregation calls
criteria/common/src/org/immutables/criteria/expression/Query.java