use of org.apache.calcite.sql.fun.SqlAbstractGroupFunction in project calcite by apache.
the class AggVisitor method visit.
public Void visit(SqlCall call) {
final SqlOperator operator = call.getOperator();
// If nested aggregates disallowed or found an aggregate at invalid level
if (operator.isAggregator() && !(operator instanceof SqlAbstractGroupFunction) && !operator.requiresOver()) {
if (delegate != null) {
return operator.acceptCall(delegate, call);
}
if (aggregate) {
return found(call);
}
}
if (group && operator.isGroup()) {
return found(call);
}
// User-defined function may not be resolved yet.
if (operator instanceof SqlFunction) {
final SqlFunction sqlFunction = (SqlFunction) operator;
if (sqlFunction.getFunctionType().isUserDefinedNotSpecificFunction()) {
final List<SqlOperator> list = Lists.newArrayList();
opTab.lookupOperatorOverloads(sqlFunction.getSqlIdentifier(), sqlFunction.getFunctionType(), SqlSyntax.FUNCTION, list);
for (SqlOperator operator2 : list) {
if (operator2.isAggregator() && !operator2.requiresOver()) {
// level
if (aggregate) {
found(call);
}
}
}
}
}
if (call.isA(SqlKind.QUERY)) {
// don't traverse into queries
return null;
}
if (call.getKind() == SqlKind.OVER) {
if (over) {
return found(call);
} else {
// an aggregate function over a window is not an aggregate!
return null;
}
}
return super.visit(call);
}
Aggregations