use of org.apache.asterix.lang.sqlpp.clause.Projection in project asterixdb by apache.
the class SqlppAstPrintVisitor method visit.
@Override
public Void visit(SelectRegular selectRegular, Integer step) throws CompilationException {
out.println(skip(step) + "SELECT [");
for (Projection projection : selectRegular.getProjections()) {
projection.accept(this, step);
}
out.println(skip(step) + "]");
return null;
}
use of org.apache.asterix.lang.sqlpp.clause.Projection in project asterixdb by apache.
the class SqlppFormatPrintVisitor method visit.
@Override
public Void visit(SelectRegular selectRegular, Integer step) throws CompilationException {
out.print("select ");
int index = 0;
for (Projection projection : selectRegular.getProjections()) {
if (index > 0) {
out.print(COMMA);
}
projection.accept(this, step);
++index;
}
return null;
}
use of org.apache.asterix.lang.sqlpp.clause.Projection in project asterixdb by apache.
the class SqlppExpressionToPlanTranslator method generateReturnExpr.
// Generates the return expression for a select clause.
private Expression generateReturnExpr(SelectClause selectClause, SelectBlock selectBlock) {
SelectRegular selectRegular = selectClause.getSelectRegular();
List<FieldBinding> fieldBindings = new ArrayList<>();
List<Projection> projections = selectRegular.getProjections();
for (Projection projection : projections) {
if (projection.star()) {
if (selectBlock.hasGroupbyClause()) {
fieldBindings.addAll(getGroupBindings(selectBlock.getGroupbyClause()));
} else if (selectBlock.hasFromClause()) {
fieldBindings.addAll(getFromBindings(selectBlock.getFromClause()));
}
} else {
fieldBindings.add(new FieldBinding(new LiteralExpr(new StringLiteral(projection.getName())), projection.getExpression()));
}
}
return new RecordConstructor(fieldBindings);
}
Aggregations