use of org.apache.asterix.lang.aql.expression.FLWOGRExpression in project asterixdb by apache.
the class AQLCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(FLWOGRExpression flwor, VariableSubstitutionEnvironment env) throws CompilationException {
List<Clause> newClauses = new ArrayList<Clause>(flwor.getClauseList().size());
VariableSubstitutionEnvironment currentEnv = env;
for (Clause c : flwor.getClauseList()) {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = c.accept(this, currentEnv);
currentEnv = p1.second;
newClauses.add((Clause) p1.first);
}
Pair<ILangExpression, VariableSubstitutionEnvironment> p2 = flwor.getReturnExpr().accept(this, currentEnv);
Expression newReturnExpr = (Expression) p2.first;
FLWOGRExpression newFlwor = new FLWOGRExpression(newClauses, newReturnExpr);
return new Pair<ILangExpression, VariableSubstitutionEnvironment>(newFlwor, p2.second);
}
use of org.apache.asterix.lang.aql.expression.FLWOGRExpression in project asterixdb by apache.
the class AqlQueryRewriter method wrapInLets.
private void wrapInLets() {
// it into a let clause.
if (topStatement == null) {
return;
}
Expression body = topStatement.getBody();
if (body.getKind() != Kind.FLWOGR_EXPRESSION) {
VarIdentifier var = context.newVariable();
VariableExpr v = new VariableExpr(var);
LetClause c1 = new LetClause(v, body);
ArrayList<Clause> clauseList = new ArrayList<>(1);
clauseList.add(c1);
FLWOGRExpression newBody = new FLWOGRExpression(clauseList, new VariableExpr(var));
topStatement.setBody(newBody);
}
}
Aggregations