use of com.developmentontheedge.sql.model.AstCount in project be5 by DevelopmentOnTheEdge.
the class CountApplier method transform.
public void transform(ParserContext ctx, AstStart ast) {
AstQuery query = ast.getQuery();
query.children().select(AstSelect.class).forEach(AstSelect::dropOrder);
if (query.jjtGetNumChildren() > 1)
throw new UnsupportedOperationException("UNION queries are not supported for COUNT");
AstSelect select = query.children().select(AstSelect.class).findFirst().get();
AstSelectList selectList = select.getSelectList();
selectList.removeChildren();
AstCount countFn = new AstCount();
AstDerivedColumn countNode = new AstDerivedColumn(countFn, "CNT");
countNode.setAsToken(true);
selectList.addChild(countNode);
}
Aggregations