So it's not absolutely necessary this query be int...
# general
e
So it's not absolutely necessary this query be interpreted as an ansi sql query then - can be a shorthand. Just might be confusing for a user who didn't intend to issue that query, i.e. they forgot to add the group by clause... like me when I was testing this 🙂
k
Looks like there is some code to validate this but might be buggy
Copy code
// Sanity check group by query: All non-aggregate expression in selection list should be also included in group by list.
for (Expression selectExpression : pinotQuery.getSelectList()) {
  if (!isAggregateExpression(selectExpression)) {
    boolean foundInGroupByClause = false;
    Expression selectionToCheck;
    if (selectExpression.getFunctionCall() != null && selectExpression.getFunctionCall().getOperator()
        .equalsIgnoreCase(<http://SqlKind.AS|SqlKind.AS>.toString())) {
      selectionToCheck = selectExpression.getFunctionCall().getOperands().get(0);
    } else {
      selectionToCheck = selectExpression;
    }
    for (Expression groupByExpression : pinotQuery.getGroupByList()) {
      if (groupByExpression.equals(selectionToCheck)) {
        foundInGroupByClause = true;
      }
    }
    if (!foundInGroupByClause) {
      throw new SqlCompilationException(
          "'" + RequestUtils.prettyPrint(selectionToCheck) + "' should appear in GROUP BY clause.");
    }
  }
}
In CalciteSqlParser