use of org.apache.asterix.lang.sqlpp.clause.SelectRegular in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public SelectClause visit(SelectClause selectClause, Void arg) throws CompilationException {
SelectElement selectElement = null;
SelectRegular selectRegular = null;
if (selectClause.selectElement()) {
selectElement = (SelectElement) selectClause.getSelectElement().accept(this, arg);
}
if (selectClause.selectRegular()) {
selectRegular = (SelectRegular) selectClause.getSelectRegular().accept(this, arg);
}
return new SelectClause(selectElement, selectRegular, selectClause.distinct());
}
use of org.apache.asterix.lang.sqlpp.clause.SelectRegular 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