Search in sources :

Example 11 with FromTerm

use of org.apache.asterix.lang.sqlpp.clause.FromTerm 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;
}
Also used : VariableExpr(org.apache.asterix.lang.common.expression.VariableExpr) FromTerm(org.apache.asterix.lang.sqlpp.clause.FromTerm) HashSet(java.util.HashSet)

Aggregations

FromTerm (org.apache.asterix.lang.sqlpp.clause.FromTerm)11 VariableExpr (org.apache.asterix.lang.common.expression.VariableExpr)6 SelectExpression (org.apache.asterix.lang.sqlpp.expression.SelectExpression)5 ArrayList (java.util.ArrayList)4 Expression (org.apache.asterix.lang.common.base.Expression)4 ILangExpression (org.apache.asterix.lang.common.base.ILangExpression)4 FromClause (org.apache.asterix.lang.sqlpp.clause.FromClause)4 SelectBlock (org.apache.asterix.lang.sqlpp.clause.SelectBlock)3 SelectClause (org.apache.asterix.lang.sqlpp.clause.SelectClause)3 SelectElement (org.apache.asterix.lang.sqlpp.clause.SelectElement)3 SelectSetOperation (org.apache.asterix.lang.sqlpp.clause.SelectSetOperation)3 SetOperationInput (org.apache.asterix.lang.sqlpp.struct.SetOperationInput)3 VariableSubstitutionEnvironment (org.apache.asterix.lang.common.rewrites.VariableSubstitutionEnvironment)2 AbstractBinaryCorrelateClause (org.apache.asterix.lang.sqlpp.clause.AbstractBinaryCorrelateClause)2 CaseExpression (org.apache.asterix.lang.sqlpp.expression.CaseExpression)2 Pair (org.apache.hyracks.algebricks.common.utils.Pair)2 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 FunctionSignature (org.apache.asterix.common.functions.FunctionSignature)1 LimitClause (org.apache.asterix.lang.common.clause.LimitClause)1