use of org.apache.asterix.lang.sqlpp.clause.JoinClause in project asterixdb by apache.
the class DeepCopyVisitor method visit.
@Override
public JoinClause visit(JoinClause joinClause, Void arg) throws CompilationException {
Expression rightExpression = (Expression) joinClause.getRightExpression().accept(this, arg);
VariableExpr rightVar = (VariableExpr) joinClause.getRightVariable().accept(this, arg);
VariableExpr rightPositionVar = joinClause.getPositionalVariable() == null ? null : (VariableExpr) joinClause.getPositionalVariable().accept(this, arg);
Expression conditionExpresion = (Expression) joinClause.getConditionExpression().accept(this, arg);
return new JoinClause(joinClause.getJoinType(), rightExpression, rightVar, rightPositionVar, conditionExpresion);
}
use of org.apache.asterix.lang.sqlpp.clause.JoinClause in project asterixdb by apache.
the class SqlppCloneAndSubstituteVariablesVisitor method visit.
@Override
public Pair<ILangExpression, VariableSubstitutionEnvironment> visit(JoinClause joinClause, VariableSubstitutionEnvironment env) throws CompilationException {
VariableExpr rightVar = joinClause.getRightVariable();
VariableExpr newRightVar = generateNewVariable(context, rightVar);
VariableExpr newRightPosVar = joinClause.hasPositionalVariable() ? generateNewVariable(context, joinClause.getPositionalVariable()) : null;
// Visits the right expression.
Expression newRightExpr = (Expression) visitUnnesBindingExpression(joinClause.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.
Expression conditionExpr = (Expression) joinClause.getConditionExpression().accept(this, currentEnv).first;
JoinClause newJoinClause = new JoinClause(joinClause.getJoinType(), newRightExpr, newRightVar, newRightPosVar, conditionExpr);
return new Pair<>(newJoinClause, currentEnv);
}
Aggregations