use of org.apache.asterix.lang.common.clause.LetClause in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public SelectBlock visit(SelectBlock selectBlock, Void arg) throws CompilationException {
FromClause fromClause = null;
List<LetClause> letClauses = new ArrayList<>();
WhereClause whereClause = null;
GroupbyClause gbyClause = null;
List<LetClause> gbyLetClauses = new ArrayList<>();
HavingClause havingClause = null;
SelectClause selectCluase;
// "group by", "let"s, "having" and "select".
if (selectBlock.hasFromClause()) {
fromClause = (FromClause) selectBlock.getFromClause().accept(this, arg);
}
if (selectBlock.hasLetClauses()) {
List<LetClause> letList = selectBlock.getLetList();
for (LetClause letClause : letList) {
letClauses.add((LetClause) letClause.accept(this, arg));
}
}
if (selectBlock.hasWhereClause()) {
whereClause = (WhereClause) selectBlock.getWhereClause().accept(this, arg);
}
if (selectBlock.hasGroupbyClause()) {
gbyClause = (GroupbyClause) selectBlock.getGroupbyClause().accept(this, arg);
}
if (selectBlock.hasLetClausesAfterGroupby()) {
List<LetClause> letListAfterGby = selectBlock.getLetListAfterGroupby();
for (LetClause letClauseAfterGby : letListAfterGby) {
gbyLetClauses.add((LetClause) letClauseAfterGby.accept(this, arg));
}
}
if (selectBlock.hasHavingClause()) {
havingClause = (HavingClause) selectBlock.getHavingClause().accept(this, arg);
}
selectCluase = (SelectClause) selectBlock.getSelectClause().accept(this, arg);
return new SelectBlock(selectCluase, fromClause, letClauses, whereClause, gbyClause, gbyLetClauses, havingClause);
}
use of org.apache.asterix.lang.common.clause.LetClause 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());
}
use of org.apache.asterix.lang.common.clause.LetClause in project asterixdb by apache.
the class SqlppInlineUdfsVisitor method visit.
@Override
public Boolean visit(SelectExpression selectExpression, List<FunctionDecl> funcs) throws CompilationException {
boolean changed = false;
if (selectExpression.hasLetClauses()) {
for (LetClause letClause : selectExpression.getLetList()) {
changed |= letClause.accept(this, funcs);
}
}
changed |= selectExpression.getSelectSetOperation().accept(this, funcs);
if (selectExpression.hasOrderby()) {
changed |= selectExpression.getOrderbyClause().accept(this, funcs);
}
if (selectExpression.hasLimit()) {
changed |= selectExpression.getLimitClause().accept(this, funcs);
}
return changed;
}
Aggregations