use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class ExpressionToVariableUtil method getGeneratedVariable.
/**
* Generates a variable according to an expression.
*
* @param expr
* the input expression.
* @param raiseError,
* if it is not possible to generate a variable from the input expression,
* to raise the error if true, and to return a null if false.
* @return the generated variable.
* @throws ParseException
*/
public static VariableExpr getGeneratedVariable(Expression expr, boolean raiseError) throws ParseException {
try {
String varName = getGeneratedIdentifier(expr);
VarIdentifier var = new VarIdentifier(varName);
VariableExpr varExpr = new VariableExpr();
varExpr.setVar(var);
return varExpr;
} catch (ParseException e) {
if (raiseError) {
throw e;
}
return null;
}
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public QuantifiedExpression visit(QuantifiedExpression qe, Void arg) throws CompilationException {
List<QuantifiedPair> quantifiedPairs = new ArrayList<>();
for (QuantifiedPair pair : qe.getQuantifiedList()) {
Expression expr = (Expression) pair.getExpr().accept(this, arg);
VariableExpr var = (VariableExpr) pair.getVarExpr().accept(this, arg);
quantifiedPairs.add(new QuantifiedPair(var, expr));
}
Expression condition = (Expression) qe.getSatisfiesExpr().accept(this, arg);
return new QuantifiedExpression(qe.getQuantifier(), quantifiedPairs, condition);
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public FromTerm visit(FromTerm fromTerm, Void arg) throws CompilationException {
// Visit the left expression of a from term.
Expression fromExpr = (Expression) fromTerm.getLeftExpression().accept(this, arg);
VariableExpr fromVar = (VariableExpr) fromTerm.getLeftVariable().accept(this, arg);
VariableExpr positionVar = fromTerm.getPositionalVariable() == null ? null : (VariableExpr) fromTerm.getPositionalVariable().accept(this, arg);
// Visits join/unnest/nest clauses.
List<AbstractBinaryCorrelateClause> correlateClauses = new ArrayList<>();
for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
correlateClauses.add((AbstractBinaryCorrelateClause) correlateClause.accept(this, arg));
}
return new FromTerm(fromExpr, fromVar, positionVar, correlateClauses);
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public VariableExpr visit(VariableExpr varExpr, Void arg) throws CompilationException {
VariableExpr clonedVar = new VariableExpr(new VarIdentifier(varExpr.getVar()));
clonedVar.setIsNewVar(varExpr.getIsNewVar());
return clonedVar;
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class SqlppVariableUtil method getBindingVariables.
public static Collection<VariableExpr> getBindingVariables(FromTerm fromTerm) {
List<VariableExpr> bindingVars = new ArrayList<>();
if (fromTerm == null) {
return bindingVars;
}
bindingVars.add(fromTerm.getLeftVariable());
if (fromTerm.hasPositionalVariable()) {
bindingVars.add(fromTerm.getPositionalVariable());
}
for (AbstractBinaryCorrelateClause correlateClause : fromTerm.getCorrelateClauses()) {
bindingVars.add(correlateClause.getRightVariable());
if (correlateClause.hasPositionalVariable()) {
bindingVars.add(correlateClause.getPositionalVariable());
}
}
return bindingVars;
}
Aggregations