String name = getAsString();
Expression aggregateExpr = context.expressionFor(name);
if (aggregateExpr == null) {
Expression arg = getLeft().generateExpression(context);
if (usesDistinct()) {
arg = arg.distinct();
}
aggregateExpr = addAggregateExression(arg);
context.addExpression(aggregateExpr, name);
}
return aggregateExpr;