use of org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(IfExpr ifexpr, VariableSubstitutionEnvironment env) throws CompilationException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = ifexpr.getCondExpr().accept(this, env);
Pair<ILangExpression, VariableSubstitutionEnvironment> p2 = ifexpr.getThenExpr().accept(this, env);
Pair<ILangExpression, VariableSubstitutionEnvironment> p3 = ifexpr.getElseExpr().accept(this, env);
IfExpr i = new IfExpr((Expression) p1.first, (Expression) p2.first, (Expression) p3.first);
return new Pair<>(i, env);
}
use of org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(UnaryExpr u, VariableSubstitutionEnvironment env) throws CompilationException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = u.getExpr().accept(this, env);
UnaryExpr newU = new UnaryExpr(u.getExprType(), (Expression) p1.first);
return new Pair<>(newU, env);
}
use of org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(LetClause lc, VariableSubstitutionEnvironment env) throws CompilationException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = lc.getBindingExpr().accept(this, env);
VariableExpr varExpr = lc.getVarExpr();
VariableExpr newVe = generateNewVariable(context, varExpr);
LetClause newLet = new LetClause(newVe, (Expression) p1.first);
return new Pair<>(newLet, VariableCloneAndSubstitutionUtil.eliminateSubstFromList(lc.getVarExpr(), env));
}
use of org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(LimitClause lc, VariableSubstitutionEnvironment env) throws CompilationException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = lc.getLimitExpr().accept(this, env);
Pair<ILangExpression, VariableSubstitutionEnvironment> p2;
Expression lcOffsetExpr = lc.getOffset();
if (lcOffsetExpr != null) {
p2 = lcOffsetExpr.accept(this, env);
} else {
p2 = new Pair<>(null, null);
}
LimitClause c = new LimitClause((Expression) p1.first, (Expression) p2.first);
return new Pair<>(c, env);
}
use of org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(Query q, VariableSubstitutionEnvironment env) throws CompilationException {
Query newQ = new Query(q.isExplain());
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = q.getBody().accept(this, env);
newQ.setBody((Expression) p1.first);
return new Pair<>(newQ, p1.second);
}
Aggregations