use of org.apache.asterix.lang.common.base.ILangExpression in project asterixdb by apache.
the class AQLCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(DistinctClause dc, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> exprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(dc.getDistinctByExpr(), env, this);
DistinctClause dc2 = new DistinctClause(exprList);
return new Pair<ILangExpression, VariableSubstitutionEnvironment>(dc2, env);
}
use of org.apache.asterix.lang.common.base.ILangExpression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(RecordConstructor rc, VariableSubstitutionEnvironment env) throws CompilationException {
List<FieldBinding> oldFbs = rc.getFbList();
ArrayList<FieldBinding> newFbs = new ArrayList<>(oldFbs.size());
for (FieldBinding fb : oldFbs) {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = fb.getLeftExpr().accept(this, env);
Pair<ILangExpression, VariableSubstitutionEnvironment> p2 = fb.getRightExpr().accept(this, env);
FieldBinding fb2 = new FieldBinding((Expression) p1.first, (Expression) p2.first);
newFbs.add(fb2);
}
RecordConstructor newRc = new RecordConstructor(newFbs);
return new Pair<>(newRc, env);
}
use of org.apache.asterix.lang.common.base.ILangExpression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(CallExpr pf, VariableSubstitutionEnvironment env) throws CompilationException {
List<Expression> exprList = VariableCloneAndSubstitutionUtil.visitAndCloneExprList(pf.getExprList(), env, this);
CallExpr f = new CallExpr(pf.getFunctionSignature(), exprList);
return new Pair<>(f, env);
}
use of org.apache.asterix.lang.common.base.ILangExpression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(WhereClause wc, VariableSubstitutionEnvironment env) throws CompilationException {
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = wc.getWhereExpr().accept(this, env);
WhereClause newW = new WhereClause((Expression) p1.first);
return new Pair<>(newW, p1.second);
}
use of org.apache.asterix.lang.common.base.ILangExpression in project asterixdb by apache.
the class CloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(FunctionDecl fd, VariableSubstitutionEnvironment env) throws CompilationException {
List<VarIdentifier> newList = new ArrayList<>(fd.getParamList().size());
for (VarIdentifier vi : fd.getParamList()) {
VariableExpr varExpr = new VariableExpr(vi);
if (!env.constainsOldVar(varExpr)) {
throw new CompilationException("Parameter " + vi + " does not appear in the substitution list.");
}
Expression newExpr = env.findSubstitution(varExpr);
if (newExpr.getKind() != Kind.VARIABLE_EXPRESSION) {
throw new CompilationException("Parameter " + vi + " cannot be substituted by a non-variable expression.");
}
newList.add(((VariableExpr) newExpr).getVar());
}
Pair<ILangExpression, VariableSubstitutionEnvironment> p1 = fd.getFuncBody().accept(this, env);
FunctionDecl newF = new FunctionDecl(fd.getSignature(), newList, (Expression) p1.first);
return new Pair<>(newF, env);
}
Aggregations