use of org.apache.asterix.lang.sqlpp.clause.FromTerm in project asterixdb by apache.
the class AbstractSqlppExpressionScopingVisitor method visit.
@Override
public Expression visit(FromClause fromClause, ILangExpression arg) throws CompilationException {
Scope scopeForFromClause = scopeChecker.extendCurrentScope();
for (FromTerm fromTerm : fromClause.getFromTerms()) {
fromTerm.accept(this, fromClause);
// Merges the variables defined in the current from term into the scope of the current from clause.
Scope scopeForFromTerm = scopeChecker.removeCurrentScope();
mergeScopes(scopeForFromClause, scopeForFromTerm);
}
return null;
}
use of org.apache.asterix.lang.sqlpp.clause.FromTerm in project asterixdb by apache.
the class SqlppExpressionToPlanTranslator method visit.
@Override
public Pair<ILogicalOperator, LogicalVariable> visit(FromClause fromClause, Mutable<ILogicalOperator> arg) throws CompilationException {
Mutable<ILogicalOperator> inputSrc = arg;
Pair<ILogicalOperator, LogicalVariable> topUnnest = null;
for (FromTerm fromTerm : fromClause.getFromTerms()) {
topUnnest = fromTerm.accept(this, inputSrc);
inputSrc = new MutableObject<>(topUnnest.first);
}
return topUnnest;
}
use of org.apache.asterix.lang.sqlpp.clause.FromTerm 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.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;
}
use of org.apache.asterix.lang.sqlpp.clause.FromTerm in project asterixdb by apache.
the class SqlppFormatPrintVisitor method visit.
@Override
public Void visit(FromClause fromClause, Integer step) throws CompilationException {
out.print(skip(step) + "from ");
int index = 0;
for (FromTerm fromTerm : fromClause.getFromTerms()) {
if (index > 0) {
out.print(COMMA + "\n" + skip(step + 2));
}
fromTerm.accept(this, step + 2);
++index;
}
out.println();
return null;
}
Aggregations