use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class FormatPrintVisitor method visit.
@Override
public Void visit(OrderbyClause oc, Integer step) throws CompilationException {
out.print(skip(step) + "order by ");
List<OrderModifier> mlist = oc.getModifierList();
List<Expression> list = oc.getOrderbyList();
int index = 0;
int size = list.size();
for (Expression expr : oc.getOrderbyList()) {
expr.accept(this, step);
OrderModifier orderModifier = mlist.get(index);
if (orderModifier != OrderModifier.ASC) {
out.print(" " + orderModifier.toString().toLowerCase());
}
if (++index < size) {
out.print(COMMA);
}
}
out.println();
return null;
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class FormatPrintVisitor method printDelimitedExpressions.
protected void printDelimitedExpressions(List<? extends Expression> exprs, String delimiter, int step) throws CompilationException {
int index = 0;
int size = exprs.size();
for (Expression expr : exprs) {
expr.accept(this, step);
if (++index < size) {
out.print(delimiter);
}
}
}
use of org.apache.asterix.lang.common.base.Expression 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.Expression 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);
}
use of org.apache.asterix.lang.common.base.Expression in project asterixdb by apache.
the class AbstractInlineUdfsVisitor method visit.
@Override
public Boolean visit(InsertStatement insert, List<FunctionDecl> arg) throws CompilationException {
boolean changed = false;
Expression returnExpression = insert.getReturnExpression();
if (returnExpression != null) {
Pair<Boolean, Expression> rewrittenReturnExpr = inlineUdfsInExpr(returnExpression, arg);
insert.setReturnExpression(rewrittenReturnExpr.second);
changed |= rewrittenReturnExpr.first;
}
Pair<Boolean, Expression> rewrittenBodyExpression = inlineUdfsInExpr(insert.getBody(), arg);
insert.setBody(rewrittenBodyExpression.second);
return changed || rewrittenBodyExpression.first;
}
Aggregations