Search in sources :

Example 6 with LimitClause

use of org.apache.asterix.lang.common.clause.LimitClause in project asterixdb by apache.

the class DeepCopyVisitor method visit.

@Override
public SelectExpression visit(SelectExpression selectExpression, Void arg) throws CompilationException {
    List<LetClause> lets = new ArrayList<>();
    SelectSetOperation select;
    OrderbyClause orderby = null;
    LimitClause limit = null;
    // visit let list
    if (selectExpression.hasLetClauses()) {
        for (LetClause letClause : selectExpression.getLetList()) {
            lets.add((LetClause) letClause.accept(this, arg));
        }
    }
    // visit the main select.
    select = (SelectSetOperation) selectExpression.getSelectSetOperation().accept(this, arg);
    // visit order by
    if (selectExpression.hasOrderby()) {
        List<Expression> orderExprs = new ArrayList<>();
        for (Expression orderExpr : selectExpression.getOrderbyClause().getOrderbyList()) {
            orderExprs.add((Expression) orderExpr.accept(this, arg));
        }
        orderby = new OrderbyClause(orderExprs, selectExpression.getOrderbyClause().getModifierList());
    }
    // visit limit
    if (selectExpression.hasLimit()) {
        limit = (LimitClause) selectExpression.getLimitClause().accept(this, arg);
    }
    return new SelectExpression(lets, select, orderby, limit, selectExpression.isSubquery());
}
Also used : LimitClause(org.apache.asterix.lang.common.clause.LimitClause) LetClause(org.apache.asterix.lang.common.clause.LetClause) ILangExpression(org.apache.asterix.lang.common.base.ILangExpression) Expression(org.apache.asterix.lang.common.base.Expression) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression) CaseExpression(org.apache.asterix.lang.sqlpp.expression.CaseExpression) QuantifiedExpression(org.apache.asterix.lang.common.expression.QuantifiedExpression) SelectSetOperation(org.apache.asterix.lang.sqlpp.clause.SelectSetOperation) ArrayList(java.util.ArrayList) OrderbyClause(org.apache.asterix.lang.common.clause.OrderbyClause) SelectExpression(org.apache.asterix.lang.sqlpp.expression.SelectExpression)

Aggregations

LimitClause (org.apache.asterix.lang.common.clause.LimitClause)6 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)5 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)5 Expression (org.apache.asterix.lang.common.base.Expression)4 OrderbyClause (org.apache.asterix.lang.common.clause.OrderbyClause)4 ArrayList (java.util.ArrayList)3 LetClause (org.apache.asterix.lang.common.clause.LetClause)3 QuantifiedExpression (org.apache.asterix.lang.common.expression.QuantifiedExpression)3 SelectSetOperation (org.apache.asterix.lang.sqlpp.clause.SelectSetOperation)3 GbyVariableExpressionPair (org.apache.asterix.lang.common.expression.GbyVariableExpressionPair)2 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)2 VariableSubstitutionEnvironment (org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment)2 FromClause (org.apache.asterix.lang.sqlpp.clause.FromClause)2 SelectClause (org.apache.asterix.lang.sqlpp.clause.SelectClause)2 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)2 Pair (org.apache.hyracks.algebricks.common.utils.Pair)2 HashSet (java.util.HashSet)1 GroupbyClause (org.apache.asterix.lang.common.clause.GroupbyClause)1 QuantifiedPair (org.apache.asterix.lang.common.struct.QuantifiedPair)1 FromTerm (org.apache.asterix.lang.sqlpp.clause.FromTerm)1