use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class AQLAstPrintVisitor method visit.
@Override
public Void visit(UnionExpr u, Integer step) throws CompilationException {
out.println(skip(step) + "Union [");
for (Expression expr : u.getExprs()) {
expr.accept(this, step + 1);
}
out.println(skip(step) + "]");
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class AQLCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(UnionExpr u, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> exprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(u.getExprs(), env, this);
UnionExpr newU = new UnionExpr(exprList);
return new Pair<ILangExpression, VariableSubstitutionEnvironment>(newU, env);
}
use of org.apache.asterix.lang.common.base.Expression 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.common.base.Expression 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);
}
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class SqlppCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(CaseExpression caseExpr, VariableSubstitutionEnvironment env) throws CompilationException {
Expression conditionExpr = (Expression) caseExpr.getConditionExpr().accept(this, env).first;
List<Expression> whenExprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(caseExpr.getWhenExprs(), env, this);
List<Expression> thenExprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(caseExpr.getThenExprs(), env, this);
Expression elseExpr = (Expression) caseExpr.getElseExpr().accept(this, env).first;
CaseExpression newCaseExpr = new CaseExpression(conditionExpr, whenExprList, thenExprList, elseExpr);
return new Pair<>(newCaseExpr, env);
}
Aggregations