use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class SqlppVariableUtil method getLiveVariables.
public static Set<VariableExpr> getLiveVariables(Scope scope, boolean includeWithVariables) {
Set<VariableExpr> results = new HashSet<>();
Set<VariableExpr> liveVars = scope.getLiveVariables();
Iterator<VariableExpr> liveVarIter = liveVars.iterator();
while (liveVarIter.hasNext()) {
VariableExpr liveVar = liveVarIter.next();
// ordered lists with UNION item type. Currently it is typed as [ANY].
if (includeWithVariables || !liveVar.getVar().namedValueAccess()) {
results.add(liveVar);
}
}
return results;
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public UnnestClause visit(UnnestClause unnestClause, Void arg) throws CompilationException {
Expression rightExpression = (Expression) unnestClause.getRightExpression().accept(this, arg);
VariableExpr rightVar = (VariableExpr) unnestClause.getRightVariable().accept(this, arg);
VariableExpr rightPositionVar = unnestClause.getPositionalVariable() == null ? null : (VariableExpr) unnestClause.getPositionalVariable().accept(this, arg);
return new UnnestClause(unnestClause.getJoinType(), rightExpression, rightVar, rightPositionVar);
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class FreeVariableVisitor method visit.
@Override
public Void visit(SelectExpression selectExpression, Collection<VariableExpr> freeVars) throws CompilationException {
Collection<VariableExpr> letsFreeVars = new HashSet<>();
Collection<VariableExpr> selectFreeVars = new HashSet<>();
visitLetClauses(selectExpression.getLetList(), letsFreeVars);
// visit order by
if (selectExpression.hasOrderby()) {
for (Expression orderExpr : selectExpression.getOrderbyClause().getOrderbyList()) {
orderExpr.accept(this, selectFreeVars);
}
}
// visit limit
if (selectExpression.hasLimit()) {
selectExpression.getLimitClause().accept(this, selectFreeVars);
}
// visit the main select
selectExpression.getSelectSetOperation().accept(this, selectFreeVars);
// Removed let binding variables.
selectFreeVars.removeAll(SqlppVariableUtil.getBindingVariables(selectExpression.getLetList()));
freeVars.addAll(letsFreeVars);
freeVars.addAll(selectFreeVars);
return null;
}
use of org.apache.asterix.lang.common.expression.VariableExpr in project asterixdb by apache.
the class FreeVariableVisitor method visit.
@Override
public Void visit(FromClause fromClause, Collection<VariableExpr> freeVars) throws CompilationException {
Collection<VariableExpr> bindingVars = new HashSet<>();
for (FromTerm fromTerm : fromClause.getFromTerms()) {
Collection<VariableExpr> fromTermFreeVars = new HashSet<>();
fromTerm.accept(this, fromTermFreeVars);
// Since a right from term can refer to variables defined in a left from term,
// we remove binding variables from the free variables.
fromTermFreeVars.removeAll(bindingVars);
// Adds binding variables.
bindingVars.addAll(SqlppVariableUtil.getBindingVariables(fromTerm));
// Adds into freeVars.
freeVars.addAll(fromTermFreeVars);
}
return null;
}
Aggregations