use of org.apache.asterix.lang.sqlpp.clause.UnnestClause in project asterixdb by apache.
the class SqlppCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(UnnestClause unnestClause, VariableSubstitutionEnvironment env) throws CompilationException {
VariableExpr rightVar = unnestClause.getRightVariable();
VariableExpr newRightVar = generateNewVariable(context, rightVar);
VariableExpr newRightPosVar = unnestClause.hasPositionalVariable() ? generateNewVariable(context, unnestClause.getPositionalVariable()) : null;
// Visits the right expression.
Expression rightExpr = (Expression) visitUnnesBindingExpression(unnestClause.getRightExpression(), env).first;
// Visits the condition.
VariableSubstitutionEnvironment currentEnv = new VariableSubstitutionEnvironment(env);
currentEnv.removeSubstitution(newRightVar);
if (newRightPosVar != null) {
currentEnv.removeSubstitution(newRightPosVar);
}
// The condition can refer to the newRightVar and newRightPosVar.
UnnestClause newJoinClause = new UnnestClause(unnestClause.getJoinType(), rightExpr, newRightVar, newRightPosVar);
return new Pair<>(newJoinClause, currentEnv);
}
use of org.apache.asterix.lang.sqlpp.clause.UnnestClause 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);
}
Aggregations