Search in sources :

Example 1 with Projection

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;
}
Also used : Projection(org.apache.asterix.lang.sqlpp.clause.Projection)

Example 2 with Projection

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;
}
Also used : Projection(org.apache.asterix.lang.sqlpp.clause.Projection)

Example 3 with Projection

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);
}
Also used : SelectRegular(org.apache.asterix.lang.sqlpp.clause.SelectRegular) StringLiteral(org.apache.asterix.lang.common.literal.StringLiteral) ArrayList(java.util.ArrayList) FieldBinding(org.apache.asterix.lang.common.expression.FieldBinding) Projection(org.apache.asterix.lang.sqlpp.clause.Projection) LiteralExpr(org.apache.asterix.lang.common.expression.LiteralExpr) RecordConstructor(org.apache.asterix.lang.common.expression.RecordConstructor)

Aggregations

Projection (org.apache.asterix.lang.sqlpp.clause.Projection)3 ArrayList (java.util.ArrayList)1 FieldBinding (org.apache.asterix.lang.common.expression.FieldBinding)1 LiteralExpr (org.apache.asterix.lang.common.expression.LiteralExpr)1 RecordConstructor (org.apache.asterix.lang.common.expression.RecordConstructor)1 StringLiteral (org.apache.asterix.lang.common.literal.StringLiteral)1 SelectRegular (org.apache.asterix.lang.sqlpp.clause.SelectRegular)1